diff --git a/WeakAuras/Animations.lua b/WeakAuras/Animations.lua index 40b5c58..65d7f36 100644 --- a/WeakAuras/Animations.lua +++ b/WeakAuras/Animations.lua @@ -460,4 +460,4 @@ function Private.CancelAnimation(region, resetPos, resetAlpha, resetScale, reset else return false; end -end +end \ No newline at end of file diff --git a/WeakAuras/AuraEnvironment.lua b/WeakAuras/AuraEnvironment.lua index 4eab025..da01f41 100644 --- a/WeakAuras/AuraEnvironment.lua +++ b/WeakAuras/AuraEnvironment.lua @@ -461,9 +461,9 @@ local FakeWeakAurasMixin = { return data and CopyTable(data) or nil end, clones = MakeDeprecated(Private.clones, "clones", - L["Using WeakAuras.clones is deprecated. Use WeakAuras.GetRegion(id, cloneId) instead."]), + L["Using WeakAuras.clones is deprecated. Use WeakAuras.GetRegion(id, cloneId) instead."]), regions = MakeDeprecated(Private.regions, "regions", - L["Using WeakAuras.regions is deprecated. Use WeakAuras.GetRegion(id) instead."]), + L["Using WeakAuras.regions is deprecated. Use WeakAuras.GetRegion(id) instead."]), GetAllDBMTimers = function() return Private.ExecEnv.BossMods.DBM:GetAllTimers() end, GetDBMTimerById = function(...) return Private.ExecEnv.BossMods.DBM:GetTimerById(...) end, GetDBMTimer = function(...) return Private.ExecEnv.BossMods.DBM:GetTimer(...) end, diff --git a/WeakAuras/AuraWarnings.lua b/WeakAuras/AuraWarnings.lua index 7561ef1..70b42e7 100644 --- a/WeakAuras/AuraWarnings.lua +++ b/WeakAuras/AuraWarnings.lua @@ -150,6 +150,7 @@ function Private.AuraWarnings.GetAllWarnings(uid) thisWarnings[key].auraId = auraId end end + -- Order them by severity, keeping just one per severity for key, warning in pairs(thisWarnings) do results[warning.severity] = { diff --git a/WeakAuras/BuffTrigger2.lua b/WeakAuras/BuffTrigger2.lua index 1cb1774..85cf761 100644 --- a/WeakAuras/BuffTrigger2.lua +++ b/WeakAuras/BuffTrigger2.lua @@ -1,6 +1,5 @@ ---[[ BuffTrigger2.lua -This file contains the "aura2" trigger for buffs and debuffs. It is intended to replace -the buff trigger old BuffTrigger at some future point +--[=[ BuffTrigger2.lua +This file contains the "aura2" trigger for buffs and debuffs. It has replaced the older Bufftrigger 1, which is now gone. It registers the BuffTrigger table for the trigger type "aura2" and has the following API: @@ -43,7 +42,7 @@ Returns the tooltip text for additional properties. GetTriggerConditions(data, triggernum) Returns the potential conditions for a trigger -]]-- +]=]-- if not WeakAuras.IsLibsOK() then return end local AddonName, Private = ... @@ -60,8 +59,8 @@ local triggerInfos = {} local watched_trigger_events = Private.watched_trigger_events +-- Active scan functions used to quickly check which apply to a aura instance -- keyed on unit, debuffType, spellname, with a scan object value --- scan object: id, triggernum, scanFunc local scanFuncName = {} local scanFuncSpellId = {} local scanFuncGeneral = {} @@ -73,7 +72,7 @@ local scanFuncGeneralGroup = {} -- Contains all scanFuncs that should be check if the existence of a unit changed local unitExistScanFunc = {} --- Which units exist +-- Which units exist, actually contains the GUID for the unit local existingUnits = {} -- Contains all scanFuncs that fetch the role + roleIcon @@ -113,7 +112,7 @@ local function UnitExistsFixed(unit) if #unit > 9 and unit:sub(1, 9) == "nameplate" then return nameplateExists[unit] or false end - return UnitExists(unit) or UnitGUID(unit) or false + return UnitExists(unit) and UnitGUID(unit) or false end local function UnitIsVisibleFixed(unit) @@ -249,9 +248,8 @@ local function UpdateToolTipDataInMatchData(matchData, time) if matchData.unit and matchData.index and matchData.filter then local tooltip, _, tooltip1, tooltip2, tooltip3, tooltip4 = WeakAuras.GetAuraTooltipInfo(matchData.unit, matchData.index, matchData.filter) - changed = matchData.tooltip ~= tooltip or matchData.tooltip1 ~= tooltip1 - or matchData.tooltip2 ~= tooltip2 or matchData.tooltip3 ~= tooltip3 or matchData.tooltip4 ~= tooltip4 + or matchData.tooltip2 ~= tooltip2 or matchData.tooltip3 ~= tooltip3 or matchData.tooltip4 ~= tooltip4 matchData.tooltip, matchData.tooltip1, matchData.tooltip2, matchData.tooltip3, matchData.tooltip4 = tooltip, tooltip1, tooltip2, tooltip3, tooltip4 end @@ -287,6 +285,7 @@ local function UpdateMatchData(time, matchDataChanged, unit, index, filter, name UpdateTooltip = UpdateToolTipDataInMatchData, auras = {} } + return true end @@ -786,6 +785,7 @@ local function UpdateStateWithNoMatch(time, triggerStates, triggerInfo, cloneId, state.initialTime = nil changed = true end + if state.refreshTime then state.refreshTime = nil changed = true @@ -1086,13 +1086,14 @@ local function MaxUnitCount(triggerInfo) end end + + local function TriggerInfoApplies(triggerInfo, unit) local controllingUnit = unit if WeakAuras.UnitIsPet(unit) then controllingUnit = WeakAuras.petUnitToUnit[unit] end - if triggerInfo.ignoreSelf and UnitIsUnit("player", controllingUnit) then return false end @@ -1265,7 +1266,7 @@ local function UpdateTriggerState(time, id, triggernum) local cloneId = "" local useMatch = true - if triggerInfo.unitExists ~= nil and not existingUnits[triggerInfo.unit] then + if triggerInfo.unitExists ~= nil and not UnitExistsFixed(triggerInfo.unit) then useMatch = triggerInfo.unitExists else useMatch = SatisfiesGroupMatchCount(triggerInfo, unitCount, maxUnitCount, matchCount) @@ -1321,7 +1322,7 @@ local function UpdateTriggerState(time, id, triggernum) end local useMatches = true - if triggerInfo.unitExists ~= nil and not existingUnits[triggerInfo.unit] then + if triggerInfo.unitExists ~= nil and not UnitExistsFixed(triggerInfo.unit) then useMatches = triggerInfo.unitExists else useMatches = SatisfiesGroupMatchCount(triggerInfo, unitCount, maxUnitCount, matchCount) @@ -1346,6 +1347,7 @@ local function UpdateTriggerState(time, id, triggernum) usedCloneIds[cloneId] = 1 end + local role = roleForTriggerInfo(triggerInfo, auraData.unit) local mark = markForTriggerInfo(triggerInfo, auraData.unit) updated = UpdateStateWithMatch(time, auraData, triggerStates, cloneId, matchCount, unitCount, maxUnitCount, @@ -1466,7 +1468,6 @@ local function UpdateTriggerState(time, id, triggernum) Private.AddToWatchedTriggerDelay(id, triggernum) end end - return updated end @@ -1517,7 +1518,7 @@ local function CleanUpOutdatedMatchData(removeIndex, unit, filter) matchDataChanged[id] = matchDataChanged[id] or {} matchDataChanged[id][triggernum] = true end - end + end end end end @@ -1660,7 +1661,7 @@ local function ScanRaidMarkScanFunc(matchDataChanged) end local function ScanGroupUnit(time, matchDataChanged, unitType, unit) - local unitExists = UnitExistsFixed(unit) == 1 and true or false + local unitExists = UnitExistsFixed(unit) if existingUnits[unit] ~= unitExists then existingUnits[unit] = unitExists @@ -1834,8 +1835,8 @@ end local Buff2Frame = CreateFrame("Frame") Private.frames["WeakAuras Buff2 Frame"] = Buff2Frame -local function EventHandler(frame, event, arg1, arg2, ...) +local function EventHandler(frame, event, arg1, arg2, ...) Private.StartProfileSystem("bufftrigger2") local deactivatedTriggerInfos = {} @@ -2107,7 +2108,7 @@ local function LoadAura(id, triggernum, triggerInfo) tinsert(unitExistScanFunc[triggerInfo.unit][id], triggerInfo) if existingUnits[triggerInfo.unit] == nil then - existingUnits[triggerInfo.unit] = UnitExistsFixed(triggerInfo.unit) == 1 and true or false + existingUnits[triggerInfo.unit] = UnitExistsFixed(triggerInfo.unit) end end @@ -2181,7 +2182,6 @@ function BuffTrigger.UnloadDisplays(toUnload) matchDataChanged[id] = nil end - for unitType, funcs in pairs(groupScanFuncs) do for i = #funcs, 1, -1 do if toUnload[funcs[i].id] then @@ -2197,6 +2197,7 @@ function BuffTrigger.UnloadDisplays(toUnload) end end end + end function BuffTrigger.FinishLoadUnload() @@ -2204,15 +2205,15 @@ function BuffTrigger.FinishLoadUnload() end --- Removes all data for an aura id --- @param id +--- @param id number function BuffTrigger.Delete(id) BuffTrigger.UnloadDisplays({[id] = true}) triggerInfos[id] = nil end --- Updates all data for aura oldid to use newid --- @param oldid --- @param newid +--- @param oldid number +--- @param newid number function BuffTrigger.Rename(oldid, newid) triggerInfos[newid] = triggerInfos[oldid] triggerInfos[oldid] = nil @@ -2358,7 +2359,7 @@ local function createScanFunc(trigger) return false end ]=] - ret = ret .. ret2:format(property, property, trigger.tooltipValue_operator, trigger.tooltipValue) + table.insert(ret, ret2:format(property, property, trigger.tooltipValue_operator, trigger.tooltipValue)) end if trigger.useNamePattern and trigger.namePattern_operator and trigger.namePattern_name then @@ -2620,6 +2621,7 @@ function BuffTrigger.Add(data) compareFunc = matchCombineFunctions[trigger.combineMode] or matchCombineFunctions["showLowest"], unitExists = showIfInvalidUnit, fetchTooltip = not IsSingleMissing(trigger) and trigger.unit ~= "multi" and trigger.fetchTooltip, + fetchRole = trigger.unit ~= "multi" and trigger.fetchRole, fetchRaidMark = trigger.unit ~= "multi" and trigger.fetchRaidMark, groupTrigger = IsGroupTrigger(trigger), ignoreSelf = effectiveIgnoreSelf, @@ -2648,16 +2650,16 @@ function BuffTrigger.Add(data) end --- Returns a table containing the names of all overlays --- @param data --- @param triggernum +--- @param data table +--- @param triggernum number function BuffTrigger.GetOverlayInfo(data, triggernum) return {} end --- Returns whether the trigger can have clones. --- @param data --- @param triggernum --- @return +--- @param data table +--- @param triggernum number +--- @return boolean local function CanHaveClones(data, triggernum) local trigger = data.triggers[triggernum].trigger if not IsSingleMissing(trigger) and trigger.showClones then @@ -2667,13 +2669,14 @@ local function CanHaveClones(data, triggernum) end ---Returns the type of tooltip to show for the trigger. --- @param data --- @param triggernum --- @return string +--- @param data table +--- @param triggernum number +--- @return string function BuffTrigger.CanHaveTooltip(data, triggernum) return "aura" end +--- @return boolean function BuffTrigger.SetToolTip(trigger, state) if not state.unit or not state.index then return false @@ -2725,9 +2728,9 @@ function BuffTrigger.GetNameAndIconSimple(data, triggernum) end --- Returns the name and icon to show in the options. --- @param data --- @param triggernum --- @return name and icon +--- @param data table +--- @param triggernum number +--- @return string|nil name, any icon function BuffTrigger.GetNameAndIcon(data, triggernum) local name, icon = BuffTrigger.GetNameAndIconSimple(data, triggernum) if (not name or not icon and WeakAuras.spellCache) then @@ -2745,12 +2748,13 @@ function BuffTrigger.GetNameAndIcon(data, triggernum) end --- Returns the tooltip text for additional properties. --- @param data --- @param triggernum --- @return string of additional properties +--- @param data table +--- @param triggernum number +--- @return table @additional properties function BuffTrigger.GetAdditionalProperties(data, triggernum) local trigger = data.triggers[triggernum].trigger local props = {} + props["spellId"] = L["Spell ID"] props["debuffClass"] = L["Debuff Class"] props["debuffClassIcon"] = L["Debuff Class Icon"] @@ -2760,6 +2764,7 @@ function BuffTrigger.GetAdditionalProperties(data, triggernum) if trigger.unit ~= "multi" then props["unit"] = L["Unit"] end + props["unitName"] = L["Unit Name"] props["matchCount"] = L["Match Count"] props["matchCountPerUnit"] = L["Match Count per Unit"] @@ -2837,6 +2842,7 @@ function BuffTrigger.GetProgressSources(data, triggernum, values) type = "number", display = L["Total stacks over all matches"] }) + if not IsSingleMissing(trigger) and trigger.unit ~= "multi" and trigger.fetchTooltip then tinsert(values, { trigger = triggernum, @@ -2857,6 +2863,7 @@ function BuffTrigger.GetProgressSources(data, triggernum, values) display = L["Tooltip 3"] }) end + tinsert(values, { trigger = triggernum, property = "expirationTime", @@ -2974,7 +2981,7 @@ function BuffTrigger.GetTriggerConditions(data, triggernum) end if not IsGroupTrigger(trigger) and trigger.matchesShowOn == "showAlways" - or IsGroupTrigger(trigger) and trigger.showClones and trigger.unit ~= "multi" and trigger.combinePerUnit + or IsGroupTrigger(trigger) and trigger.showClones and trigger.unit ~= "multi" and trigger.combinePerUnit then result["buffed"] = { display = L["Aura(s) Found"], @@ -3581,7 +3588,7 @@ end function BuffTrigger.InitMultiAura() if not multiAuraFrame then - multiAuraFrame = CreateFrame("frame") + multiAuraFrame = CreateFrame("Frame") multiAuraFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") multiAuraFrame:RegisterEvent("UNIT_TARGET") multiAuraFrame:RegisterEvent("UNIT_AURA") diff --git a/WeakAuras/Conditions.lua b/WeakAuras/Conditions.lua index a116dd6..89a301f 100644 --- a/WeakAuras/Conditions.lua +++ b/WeakAuras/Conditions.lua @@ -101,7 +101,9 @@ local function formatValueForAssignment(vType, value, pathToCustomFunction, path return "nil" elseif(vType == "color") then if (value and type(value) == "table") then - return string.format("{%s, %s, %s, %s}", tostring(value[1]), tostring(value[2]), tostring(value[3]), tostring(value[4])); + return string.format("{%s, %s, %s, %s}", + tostring(value[1]), tostring(value[2]), + tostring(value[3]), tostring(value[4])) end return "{1, 1, 1, 1}"; elseif(vType == "chat") then @@ -168,6 +170,7 @@ local function formatValueForCall(type, property) return "nil"; end + function Private.ExecEnv.CancelConditionCheck(uid, cloneId) if conditionChecksTimers.recheckHandle[uid] and conditionChecksTimers.recheckHandle[uid][cloneId] then timer:CancelTimer(conditionChecksTimers.recheckHandle[uid][cloneId]) @@ -272,20 +275,23 @@ local function CreateTestForCondition(data, input, allConditionsTemplate, usedSt if (test) then if (value) then Private.ExecEnv.conditionHelpers[uid] = Private.ExecEnv.conditionHelpers[uid] or {} - Private.ExecEnv.conditionHelpers[uid].customTestFunctions = Private.ExecEnv.conditionHelpers[uid].customTestFunctions or {} + Private.ExecEnv.conditionHelpers[uid].customTestFunctions + = Private.ExecEnv.conditionHelpers[uid].customTestFunctions or {} tinsert(Private.ExecEnv.conditionHelpers[uid].customTestFunctions, test); local testFunctionNumber = #(Private.ExecEnv.conditionHelpers[uid].customTestFunctions); local valueString = type(value) == "string" and string.format("%q", value) or value; local opString = type(op) == "string" and string.format("%q", op) or op; check = string.format("state and Private.ExecEnv.CallCustomConditionTest(%q, %s, state[%s], %s, %s, %s)", - uid, testFunctionNumber, trigger, valueString, (opString or "nil"), preambleString or "nil"); + uid, testFunctionNumber, trigger, valueString, (opString or "nil"), + preambleString or "nil") end elseif (cType == "customcheck") then if value then local customCheck = WeakAuras.LoadFunction("return " .. value) if customCheck then Private.ExecEnv.conditionHelpers[uid] = Private.ExecEnv.conditionHelpers[uid] or {} - Private.ExecEnv.conditionHelpers[uid].customTestFunctions = Private.ExecEnv.conditionHelpers[uid].customTestFunctions or {} + Private.ExecEnv.conditionHelpers[uid].customTestFunctions + = Private.ExecEnv.conditionHelpers[uid].customTestFunctions or {} tinsert(Private.ExecEnv.conditionHelpers[uid].customTestFunctions, customCheck); local testFunctionNumber = #(Private.ExecEnv.conditionHelpers[uid].customTestFunctions); @@ -298,7 +304,8 @@ local function CreateTestForCondition(data, input, allConditionsTemplate, usedSt elseif (cType == "number" and value and op) then local v = tonumber(value) if (v) then - check = stateCheck .. stateVariableCheck .. "state[" .. trigger .. "]" .. string.format("[%q]", variable) .. op .. v; + check = stateCheck .. stateVariableCheck .. "state[" .. trigger .. "]" .. string.format("[%q]", variable) + .. op .. v; end elseif (cType == "timer" and value and op) then local triggerState = "state[" .. trigger .. "]" @@ -317,15 +324,19 @@ local function CreateTestForCondition(data, input, allConditionsTemplate, usedSt end elseif (cType == "elapsedTimer" and value and op) then if (op == "==") then - check = stateCheck .. stateVariableCheck .. "abs(state[" .. trigger .. "]" .. string.format("[%q]", variable) .. "- now +" .. value .. ") < 0.05"; + check = stateCheck .. stateVariableCheck .. "abs(state[" .. trigger .. "]" .. string.format("[%q]", variable) + .. "- now +" .. value .. ") < 0.05"; else - check = stateCheck .. stateVariableCheck .. "now - state[" .. trigger .. "]" .. string.format("[%q]", variable) .. op .. value; + check = stateCheck .. stateVariableCheck .. "now - state[" .. trigger .. "]" .. string.format("[%q]", variable) + .. op .. value; end elseif (cType == "select" and value and op) then if (tonumber(value)) then - check = stateCheck .. stateVariableCheck .. "state[" .. trigger .. "]" .. string.format("[%q]", variable) .. op .. tonumber(value); + check = stateCheck .. stateVariableCheck .. "state[" .. trigger .. "]" .. string.format("[%q]", variable) + .. op .. tonumber(value); else - check = stateCheck .. stateVariableCheck .. "state[" .. trigger .. "]".. string.format("[%q]", variable) .. op .. "'" .. value .. "'"; + check = stateCheck .. stateVariableCheck .. "state[" .. trigger .. "]".. string.format("[%q]", variable) + .. op .. "'" .. value .. "'"; end elseif (cType == "range" and value and op and input.type and input.op_range and input.range) then local fn @@ -365,7 +376,8 @@ local function CreateTestForCondition(data, input, allConditionsTemplate, usedSt local customCheck = WeakAuras.LoadFunction(fn) if customCheck then Private.ExecEnv.conditionHelpers[uid] = Private.ExecEnv.conditionHelpers[uid] or {} - Private.ExecEnv.conditionHelpers[uid].customTestFunctions = Private.ExecEnv.conditionHelpers[uid].customTestFunctions or {} + Private.ExecEnv.conditionHelpers[uid].customTestFunctions + = Private.ExecEnv.conditionHelpers[uid].customTestFunctions or {} tinsert(Private.ExecEnv.conditionHelpers[uid].customTestFunctions, customCheck); local testFunctionNumber = #(Private.ExecEnv.conditionHelpers[uid].customTestFunctions); @@ -375,14 +387,18 @@ local function CreateTestForCondition(data, input, allConditionsTemplate, usedSt end elseif (cType == "bool" and value) then local rightSide = value == 0 and "false" or "true"; - check = stateCheck .. stateVariableCheck .. "state[" .. trigger .. "]" .. string.format("[%q]", variable) .. "==" .. rightSide + check = stateCheck .. stateVariableCheck .. "state[" .. trigger .. "]" .. string.format("[%q]", variable) + .. "==" .. rightSide elseif (cType == "string" and value) then if(op == "==") then - check = stateCheck .. stateVariableCheck .. "state[" .. trigger .. "]" .. string.format("[%q]", variable) .. " == [[" .. value .. "]]"; + check = stateCheck .. stateVariableCheck .. "state[" .. trigger .. "]" .. string.format("[%q]", variable) + .. " == [[" .. value .. "]]"; elseif (op == "find('%s')") then - check = stateCheck .. stateVariableCheck .. "state[" .. trigger .. "]" .. string.format("[%q]", variable) .. ":find([[" .. value .. "]], 1, true)"; + check = stateCheck .. stateVariableCheck .. "state[" .. trigger .. "]" .. string.format("[%q]", variable) + .. ":find([[" .. value .. "]], 1, true)"; elseif (op == "match('%s')") then - check = stateCheck .. stateVariableCheck .. "state[" .. trigger .. "]" .. string.format("[%q]", variable) .. ":match([[" .. value .. "]], 1, true)"; + check = stateCheck .. stateVariableCheck .. "state[" .. trigger .. "]" .. string.format("[%q]", variable) + .. ":match([[" .. value .. "]], 1, true)"; end end -- If adding a new condition type, don't forget to adjust the validator in the options code @@ -465,7 +481,7 @@ end local function CreateDeactivateCondition(ret, condition, conditionNumber, data, properties, usedProperties, debug) if (condition.changes) then table.insert(ret, " if (activatedConditions[".. conditionNumber .. "] and not newActiveConditions[" .. conditionNumber .. "]) then\n") - if (debug) then table.insert(ret, " print('Deactivating condition " .. conditionNumber .. "' )\n") end + if (debug) then table.insert(ret, " print('Deactivating condition " .. conditionNumber .. "' )\n") end for changeNum, change in ipairs(condition.changes) do if (change.property) then local propertyData = properties and properties[change.property] @@ -474,12 +490,12 @@ local function CreateDeactivateCondition(ret, condition, conditionNumber, data, table.insert(ret, " propertyChanges['" .. change.property .. "'] = " .. formatValueForAssignment(propertyData.type, GetBaseProperty(data, change.property), nil, nil, data) - .. "\n") + .. "\n") if (debug) then table.insert(ret, " print('- " .. change.property .. " " .. formatValueForAssignment(propertyData.type, GetBaseProperty(data, change.property), nil, nil, data) - .. "')\n") + .. "')\n") end end end @@ -493,8 +509,8 @@ end local function CreateActivateCondition(ret, id, condition, conditionNumber, data, properties, debug) if (condition.changes) then table.insert(ret, " if (newActiveConditions[" .. conditionNumber .. "]) then\n") - table.insert(ret, " if (not activatedConditions[".. conditionNumber .. "]) then\n") - if (debug) then table.insert(ret, " print('Activating condition " .. conditionNumber .. "' )\n") end + table.insert(ret, " if (not activatedConditions[".. conditionNumber .. "]) then\n") + if (debug) then table.insert(ret, " print('Activating condition " .. conditionNumber .. "' )\n") end -- non active => active for changeNum, change in ipairs(condition.changes) do if (change.property) then @@ -503,10 +519,10 @@ local function CreateActivateCondition(ret, id, condition, conditionNumber, data if (propertyData.setter) then table.insert(ret, " propertyChanges['" .. change.property .. "'] = " .. formatValueForAssignment(propertyData.type, change.value, nil, nil, data) .. "\n") - if (debug) then - table.insert(ret, " print('- " .. change.property .. " " - .. formatValueForAssignment(propertyData.type, change.value, nil, nil, data) .. "')\n") - end + if (debug) then + table.insert(ret, " print('- " .. change.property .. " " + .. formatValueForAssignment(propertyData.type, change.value, nil, nil, data) .. "')\n") + end elseif (propertyData.action) then local pathToCustomFunction = "nil"; local pathToFormatter = "nil" @@ -514,23 +530,25 @@ local function CreateActivateCondition(ret, id, condition, conditionNumber, data and Private.ExecEnv.customConditionsFunctions[id][conditionNumber] and Private.ExecEnv.customConditionsFunctions[id][conditionNumber].changes and Private.ExecEnv.customConditionsFunctions[id][conditionNumber].changes[changeNum]) then - pathToCustomFunction = string.format("Private.ExecEnv.customConditionsFunctions[%q][%s].changes[%s]", id, conditionNumber, changeNum); + pathToCustomFunction = string.format("Private.ExecEnv.customConditionsFunctions[%q][%s].changes[%s]", + id, conditionNumber, changeNum); end if Private.ExecEnv.conditionTextFormatters[id] and Private.ExecEnv.conditionTextFormatters[id][conditionNumber] and Private.ExecEnv.conditionTextFormatters[id][conditionNumber].changes and Private.ExecEnv.conditionTextFormatters[id][conditionNumber].changes[changeNum] then - pathToFormatter = string.format("Private.ExecEnv.conditionTextFormatters[%q][%s].changes[%s]", id, conditionNumber, changeNum); + pathToFormatter = string.format("Private.ExecEnv.conditionTextFormatters[%q][%s].changes[%s]", + id, conditionNumber, changeNum); end table.insert(ret, " region:" .. propertyData.action .. "(" - .. formatValueForAssignment(propertyData.type, change.value, - pathToCustomFunction, pathToFormatter, data) - .. ")" .. "\n") - if (debug) then - table.insert(ret, " print('# " .. propertyData.action .. "(" - .. formatValueForAssignment(propertyData.type, change.value, - pathToCustomFunction, pathToFormatter, data) - .. "')\n") + .. formatValueForAssignment(propertyData.type, change.value, + pathToCustomFunction, pathToFormatter, data) + .. ")" .. "\n") + if (debug) then + table.insert(ret, " print('# " .. propertyData.action .. "(" + .. formatValueForAssignment(propertyData.type, change.value, + pathToCustomFunction, pathToFormatter, data) + .. "')\n") end end end @@ -543,11 +561,11 @@ local function CreateActivateCondition(ret, id, condition, conditionNumber, data local propertyData = properties and properties[change.property] if (propertyData and propertyData.type and propertyData.setter) then table.insert(ret, " if(propertyChanges['" .. change.property .. "'] ~= nil) then\n") - table.insert(ret, " propertyChanges['" .. change.property .. "'] = " - .. formatValueForAssignment(propertyData.type, change.value, nil, nil, data) .. "\n") - if (debug) then table.insert(ret, " print('- " .. change.property .. " " - .. formatValueForAssignment(propertyData.type, change.value, nil, nil, data) .. "')\n") end - table.insert(ret, " end\n") + table.insert(ret, " propertyChanges['" .. change.property .. "'] = " + .. formatValueForAssignment(propertyData.type, change.value, nil, nil, data) .. "\n") + if (debug) then table.insert(ret, " print('- " .. change.property .. " " + .. formatValueForAssignment(propertyData.type, change.value, nil, nil, data) .. "')\n") end + table.insert(ret, " end\n") end end end @@ -577,8 +595,8 @@ function Private.GetSubRegionProperties(data, properties) for key, property in pairs(subProperties) do subIndex[key] = subIndex[key] and subIndex[key] + 1 or 1 property.display = { subRegionTypeData.displayName .. " " .. subIndex[key], - property.display, - property.defaultProperty } + property.display, + property.defaultProperty } properties["sub." .. index .. "." .. key ] = property; end end @@ -797,9 +815,9 @@ function Private.LoadConditionFunction(data) CancelTimers(data.uid) local checkConditionsFuncStr = ConstructConditionFunction(data); - local checkCondtionsFunc = checkConditionsFuncStr and Private.LoadFunction(checkConditionsFuncStr) + local checkConditionsFunc = checkConditionsFuncStr and Private.LoadFunction(checkConditionsFuncStr) - checkConditions[data.uid] = checkCondtionsFunc; + checkConditions[data.uid] = checkConditionsFunc; end function Private.RunConditions(region, uid, hideRegion) @@ -863,7 +881,7 @@ local function handleDynamicConditions(self, event) end local function UpdateDynamicConditionsPerUnitState(self, event, unit) - if unit and unit == self.unit then + if unit then local unitEvent = event..":"..unit if globalDynamicConditionFuncs[unitEvent] then for i, func in ipairs(globalDynamicConditionFuncs[unitEvent]) do @@ -976,8 +994,7 @@ function Private.RegisterForGlobalConditions(uid) dynamicConditionsFrame.units[unit] = CreateFrame("Frame"); dynamicConditionsFrame.units[unit]:SetScript("OnEvent", handleDynamicConditionsPerUnit); end - dynamicConditionsFrame.units[unit].unit = unit; - pcall(dynamicConditionsFrame.RegisterEvent, dynamicConditionsFrame.units[unit], unitEvent); + pcall(dynamicConditionsFrame.units[unit].RegisterUnitEvent, dynamicConditionsFrame.units[unit], unitEvent, unit); UpdateDynamicConditionsPerUnitState(dynamicConditionsFrame, event, unit) else pcall(dynamicConditionsFrame.RegisterEvent, dynamicConditionsFrame, event); @@ -994,7 +1011,7 @@ function Private.UnregisterForGlobalConditions(uid) local unitEvent, unit = event:match("([^:]+):([^:]+)") if unitEvent and unit then unit = unit:lower() - dynamicConditionsFrame.units[unit]:UnregisterEvent(unitEvent) + pcall(dynamicConditionsFrame.units[unit].UnregisterEvent, dynamicConditionsFrame.units[unit], unitEvent); elseif (event == "FRAME_UPDATE" or event == "WA_SPELL_RANGECHECK") then if (event == "FRAME_UPDATE" and dynamicConditions["WA_SPELL_RANGECHECK"] == nil) or (event == "WA_SPELL_RANGECHECK" and dynamicConditions["FRAME_UPDATE"] == nil) @@ -1003,7 +1020,7 @@ function Private.UnregisterForGlobalConditions(uid) dynamicConditionsFrame.onUpdate = false end else - dynamicConditionsFrame:UnregisterEvent(event) + pcall(dynamicConditionsFrame.UnregisterEvent, dynamicConditionsFrame, event); end dynamicConditions[event] = nil end diff --git a/WeakAuras/DebugLog.lua b/WeakAuras/DebugLog.lua index 5af1933..21642ce 100644 --- a/WeakAuras/DebugLog.lua +++ b/WeakAuras/DebugLog.lua @@ -56,7 +56,7 @@ function Private.DebugLog.Print(uid, text, ...) end if #log > 1000 then - Private.AuraWarnings.UpdateWarning(uid, "Debug_Log", "warning", + Private.AuraWarnings.UpdateWarning(uid, "Debug Log", "warning", L["Debug Log contains more than 1000 entries"], true) end @@ -73,8 +73,8 @@ function Private.DebugLog.Clear(uid) AddMessage = AddMessage } -- Dance to clear a potential console message from the AuraWarnings - Private.AuraWarnings.UpdateWarning(uid, "Debug_Log", "info") - Private.AuraWarnings.UpdateWarning(uid, "Debug_Log", "info", L["Debug Logging enabled"]) + Private.AuraWarnings.UpdateWarning(uid, "Debug Log", "info") + Private.AuraWarnings.UpdateWarning(uid, "Debug Log", "info", L["Debug Logging enabled"]) end end @@ -87,10 +87,10 @@ function Private.DebugLog.SetEnabled(uid, enable) debugLogs[uid] = { AddMessage = AddMessage } - Private.AuraWarnings.UpdateWarning(uid, "Debug_Log", "info", L["Debug Logging enabled"]) + Private.AuraWarnings.UpdateWarning(uid, "Debug Log", "info", L["Debug Logging enabled"]) else debugLogs[uid] = nil - Private.AuraWarnings.UpdateWarning(uid, "Debug_Log", "info") + Private.AuraWarnings.UpdateWarning(uid, "Debug Log", "info") end end diff --git a/WeakAuras/GenericTrigger.lua b/WeakAuras/GenericTrigger.lua index 89f468c..7be3521 100644 --- a/WeakAuras/GenericTrigger.lua +++ b/WeakAuras/GenericTrigger.lua @@ -27,7 +27,6 @@ Modernizes all generic triggers in data. ##################################################### # Helper functions mainly for the WeakAuras Options # ##################################################### - GetOverlayInfo(data, triggernum) Returns a table containing the names of all overlays @@ -41,7 +40,7 @@ GetAdditionalProperties(data, triggernum) Returns the a tooltip for the additional properties. GetProgressSources(data, triggernum, outValues) -Fills outValues with the potential progress sources + Fills outValues with the potential progress sources GetTriggerConditions(data, triggernum) Returns potential conditions that this trigger provides. @@ -51,7 +50,7 @@ local AddonName, Private = ... -- Lua APIs local tinsert, tconcat, wipe = table.insert, table.concat, wipe -local tonumber, tostring, pairs, type = tonumber, tostring, pairs, type +local tostring, pairs, type = tostring, pairs, type local error = error local WeakAuras = WeakAuras; @@ -73,6 +72,7 @@ local loaded_auras = {}; -- id to bool map local LoadEvent, HandleEvent, HandleUnitEvent, TestForTriState, TestForToggle, TestForLongString, TestForMultiSelect local ConstructTest, ConstructFunction + local nameplateExists = {} ---@param unit UnitToken @@ -93,7 +93,7 @@ end function WeakAuras.split(input) input = input or ""; local ret = {}; - local split, element = nil, nil; + local split, element = nil, nil split = input:find("[,%s]"); while(split) do element, input = input:sub(1, split-1), input:sub(split+1); @@ -202,9 +202,9 @@ function TestForMultiSelect(trigger, arg) if trigger[name] and trigger[name].multi then for value, _ in pairs(trigger[name].multi) do if not arg.test then - test = test..name.."=="..(tonumber(value) or "[["..value.."]]").." or "; + test = test..name.."=="..(tonumber(value) or ("[["..value.."]]")).." or "; else - test = test..arg.test:format(tonumber(value) or "[["..value.."]]").." or "; + test = test..arg.test:format(tonumber(value) or ("[["..value.."]]")).." or "; end any = true; end @@ -222,9 +222,9 @@ function TestForMultiSelect(trigger, arg) return test; end if not arg.test then - test = trigger[name].single and "("..name.."=="..(tonumber(value) or "[["..value.."]]")..")"; + test = trigger[name].single and "("..name.."=="..(tonumber(value) or ("[["..value.."]]"))..")"; else - test = trigger[name].single and "("..arg.test:format(tonumber(value) or "[["..value.."]]")..")"; + test = trigger[name].single and "("..arg.test:format(tonumber(value) or ("[["..value.."]]"))..")"; end end return test; @@ -420,7 +420,7 @@ function ConstructFunction(prototype, trigger) table.insert(ret, #tests > 0 and tconcat(tests, " and ") or "true") table.insert(ret, ") then\n") if(#debug > 0) then - table.insert(ret, "print('ret: true');\n") + table.insert("print('ret: true');\n") end if (prototype.statesParameter == "all") then @@ -705,6 +705,7 @@ local function RunTriggerFunc(allStates, data, id, triggernum, event, arg1, arg2 if data.trigger.unit == "group" and IsInRaid() and Private.multiUnitUnits.party[arg1] then return end + unitForUnitTrigger = arg1 cloneIdForUnitTrigger = arg1 else @@ -825,7 +826,7 @@ local function RunTriggerFunc(allStates, data, id, triggernum, event, arg1, arg2 elseif (ok and returnValue) then allStates[""] = allStates[""] or {}; local state = allStates[""]; - if (Private.EndEvent(state)) then + if(Private.EndEvent(state)) then updateTriggerState = true; end end @@ -951,9 +952,9 @@ function Private.ScanEventsInternal(event_list, event, arg1, arg2, ... ) Private.ActivateAuraEnvironment(id); local updateTriggerState = false; for triggernum, data in pairs(triggers) do - local allStates = WeakAuras.GetTriggerStateForTrigger(id, triggernum); local delay = GenericTrigger.GetDelay(data) if delay == 0 then + local allStates = WeakAuras.GetTriggerStateForTrigger(id, triggernum); if (RunTriggerFunc(allStates, data, id, triggernum, event, arg1, arg2, ...)) then updateTriggerState = true end @@ -1018,6 +1019,7 @@ end function Private.ScanEventsWatchedTrigger(id, watchedTriggernums) + if #watchedTriggernums == 0 then return end Private.StartProfileAura(id); Private.ActivateAuraEnvironment(id); local updateTriggerState = false @@ -1109,6 +1111,7 @@ function GenericTrigger.CreateFakeStates(id, triggernum) arg1 = unit end end + RunTriggerFunc(allStates, eventData, id, triggernum, "OPTIONS", arg1) local shown = 0 @@ -1466,7 +1469,7 @@ function GenericTrigger.LoadDisplays(toLoad, loadEvent, ...) for unit, events in pairs(unitEventsToRegister) do for event in pairs(events) do if not frame.unitFrames[unit] then - frame.unitFrames[unit] = CreateFrame("FRAME") + frame.unitFrames[unit] = CreateFrame("Frame") frame.unitFrames[unit].unit = unit frame.unitFrames[unit]:SetScript("OnEvent", HandleUnitEvent); end @@ -1698,7 +1701,6 @@ function GenericTrigger.Add(data, region) force_events = force_events(trigger, untrigger) end - if prototype.includePets then includePets = trigger.use_includePets == true and trigger.includePets or nil end @@ -1754,8 +1756,8 @@ function GenericTrigger.Add(data, region) local trueEvent local hasParam = false local isCLEU = false - local isUnitEvent = false local isTrigger = false + local isUnitEvent = false if event == "CLEU" or event == "COMBAT_LOG_EVENT_UNFILTERED" then warnAboutCLEUEvents = true end @@ -1772,7 +1774,7 @@ function GenericTrigger.Add(data, region) end elseif Private.InternalEventByIDList[trueEvent] then tinsert(trigger_events, trueEvent..":"..i) - elseif trueEvent:match("^UNIT_") then + elseif trueEvent:match("^UNIT_") or Private.UnitEventList[trueEvent] then isUnitEvent = true if string.lower(strsub(i, #i - 3)) == "pets" then @@ -1854,7 +1856,7 @@ function GenericTrigger.Add(data, region) tsuConditionVariables = tsuConditionVariables, prototype = prototype, ignoreOptionsEventErrors = data.information.ignoreOptionsEventErrors, - counter = counter, + counter = counter }; end end @@ -1862,7 +1864,7 @@ function GenericTrigger.Add(data, region) if warnAboutCLEUEvents then Private.AuraWarnings.UpdateWarning(data.uid, "spammy_event_warning", "error", - L["|cFFFF0000Support for unfiltered COMBAT_LOG_EVENT_UNFILTERED is deprecated|r\nCOMBAT_LOG_EVENT_UNFILTERED without a filter are disabled as it’s very performance costly.\nFind more information:\nhttps://github.com/WeakAuras/WeakAuras2/wiki/Custom-Triggers#events"]) + L["|cFFFF0000Support for unfiltered COMBAT_LOG_EVENT_UNFILTERED is deprecated|r\nCOMBAT_LOG_EVENT_UNFILTERED without a filter are disabled as it’s very performance costly.\nFind more information:\nhttps://github.com/WeakAuras/WeakAuras2/wiki/Custom-Triggers#events"]) else Private.AuraWarnings.UpdateWarning(data.uid, "spammy_event_warning") end @@ -1920,6 +1922,7 @@ do end end + --############################# --# Support code for triggers # --############################# @@ -2575,7 +2578,7 @@ do end if (startTimeCooldown > GetTime() + 2^31 / 1000) then - -- WORKAROUND WoW wraps around negative values with 2^32/1000 + -- WORKAROUND: WoW wraps around negative values with 2^32/1000 -- So if we find a cooldown in the far future, then undo the wrapping startTimeCooldown = startTimeCooldown - 2^32 / 1000 end @@ -2675,7 +2678,7 @@ do -- We check against 1.5 and gcdDuration, as apparently the durations might not match exactly. -- But there shouldn't be any trinket with a actual cd of less than 1.5 anyway - if(duration and duration > 0 and duration > 1.5 and duration ~= WeakAuras.gcdDuration()) then + if(duration > 0 and duration > 1.5 and duration ~= WeakAuras.gcdDuration()) then -- On non-GCD cooldown local endTime = startTime + duration; @@ -2909,7 +2912,7 @@ local watchUnitChange -- Nameplates only distinguish between friends and everyone else ---@param unit UnitToken ---@return string? reaction - function WeakAuras.GetPlayerReaction(unit) +function WeakAuras.GetPlayerReaction(unit) local r = UnitReaction("player", unit) if r then return r < 5 and "hostile" or "friendly" @@ -3126,6 +3129,7 @@ function WeakAuras.WatchUnitChange(unit) end end } + watchUnitChange:SetScript("OnEvent", function(self, event, unit) Private.StartProfileSystem("generictrigger unit change"); local eventsToSend = {} @@ -3954,7 +3958,6 @@ function GenericTrigger.GetAdditionalProperties(data, triggernum) elseif type(v.enable) == "boolean" then enable = v.enable end - if (enable and v.store and v.name and v.display and v.conditionType ~= "bool") then props[v.name] = v.display end @@ -3974,7 +3977,6 @@ function GenericTrigger.GetAdditionalProperties(data, triggernum) end end end - return props; end @@ -4017,16 +4019,16 @@ local commonConditions = { type = "number", }, paused = { - display = L["Is Paused"], + display =L["Is Paused"], type = "bool", test = function(state, needle) return (state.paused and 1 or 0) == needle - end, + end }, value = { display = L["Progress Value"], type = "number", - total = "total", + total = "total" }, total = { display = L["Progress Total"], @@ -4034,11 +4036,11 @@ local commonConditions = { }, stacks = { display = L["Stacks"], - type = "number", + type = "number" }, name = { display = L["Name"], - type = "string", + type = "string" }, itemInRange = { display = WeakAuras.newFeatureString .. L["Item in Range"], @@ -4099,6 +4101,7 @@ function Private.GetTsuConditionVariablesExpanded(id, triggernum) end end end + return result end end diff --git a/WeakAuras/Modernize.lua b/WeakAuras/Modernize.lua index 2ea8732..0e0d4b6 100644 --- a/WeakAuras/Modernize.lua +++ b/WeakAuras/Modernize.lua @@ -27,7 +27,7 @@ function Private.Modernize(data, oldSnapshot) if data.conditions then for conditionIndex, condition in ipairs(data.conditions) do if condition.check then - local triggernum = condition.check.trigger; + local triggernum = condition.check.trigger if triggernum then local trigger if triggernum == 0 then @@ -136,13 +136,13 @@ function Private.Modernize(data, oldSnapshot) if data.internalVersion < 9 then local function repairCheck(check) if check and check.variable == "buffed" then - local trigger = check.trigger and data.triggers[check.trigger] and data.triggers[check.trigger].trigger; + local trigger = check.trigger and data.triggers[check.trigger] and data.triggers[check.trigger].trigger if trigger then if trigger.buffShowOn == "showOnActive" then check.variable = "show" elseif trigger.buffShowOn == "showOnMissing" then check.variable = "show" - check.value = check.value == 0 and 1 or 0; + check.value = check.value == 0 and 1 or 0 end end end @@ -302,6 +302,7 @@ function Private.Modernize(data, oldSnapshot) end end end + -- Version 20 was introduced July 2019 in BfA if data.internalVersion < 20 then if data.regionType == "icon" then @@ -436,7 +437,7 @@ function Private.Modernize(data, oldSnapshot) text_anchorPoint = positions[2], anchorXOffset = 0, anchorYOffset = 0, - text_shadowColor = { 0, 0, 0, 1} , + text_shadowColor = { 0, 0, 0, 1 }, text_shadowXOffset = 1, text_shadowYOffset = -1, rotateText = data.rotateText, @@ -1169,7 +1170,7 @@ function Private.Modernize(data, oldSnapshot) if data.internalVersion < 52 then local function matchTarget(input) - return input == "target" or input == "'target'" or input == "\"target\"" or input == "%t" or input == "'%t'" or input == "\"%t\"" + return input == "target" or input == "'target'" or input == '"target"' or input == "%t" or input == "'%t'" or input == '"%t"' end if data.conditions then @@ -1201,9 +1202,7 @@ function Private.Modernize(data, oldSnapshot) local seenSymbols = {} Private.ParseTextStr(text, function(symbol) if not seenSymbols[symbol] then - if table[prefix .. symbol .. "_format"] == "timed" - and table[prefix .. symbol .. "_time_format"] == 0 - then + if table[prefix .. symbol .. "_format"] == "timed" and table[prefix .. symbol .. "_time_format"] == 0 then table[prefix .. symbol .. "_time_legacy_floor"] = true end end diff --git a/WeakAuras/RegionTypes/AuraBar.lua b/WeakAuras/RegionTypes/AuraBar.lua index 826c1dc..0ee7041 100644 --- a/WeakAuras/RegionTypes/AuraBar.lua +++ b/WeakAuras/RegionTypes/AuraBar.lua @@ -873,7 +873,9 @@ local funcs = { if (self.total ~= 0) then progress = self.value / self.total; end + self:SetProgress(progress) + if self.FrameTick then self.FrameTick = nil self.subRegionEvents:RemoveSubscriber("FrameTick", self) @@ -886,6 +888,7 @@ local funcs = { progress = 1 - progress; end self:SetProgress(progress) + if self.paused and self.FrameTick then self.FrameTick = nil self.subRegionEvents:RemoveSubscriber("FrameTick", self) diff --git a/WeakAuras/RegionTypes/DynamicGroup.lua b/WeakAuras/RegionTypes/DynamicGroup.lua index f99bfcb..350bb89 100644 --- a/WeakAuras/RegionTypes/DynamicGroup.lua +++ b/WeakAuras/RegionTypes/DynamicGroup.lua @@ -48,7 +48,8 @@ Private.regionPrototype.AddAlphaToDefault(default); local controlPointFunctions = { ["SetAnchorPoint"] = function(self, point, relativeFrame, relativePoint, offsetX, offsetY) self:ClearAllPoints(); - self.point, self.relativeFrame, self.relativePoint, self.offsetX, self.offsetY = point, relativeFrame, relativePoint, offsetX, offsetY + self.point, self.relativeFrame, self.relativePoint, self.offsetX, self.offsetY + = point, relativeFrame, relativePoint, offsetX, offsetY self.totalOffsetX = (self.animOffsetX or 0) + (self.offsetX or 0) self.totalOffsetY = (self.animOffsetY or 0) + (self.offsetY or 0) if self.relativeFrame and self.relativePoint then @@ -96,7 +97,7 @@ end local function releaseControlPoint(self, controlPoint) controlPoint:Hide() - controlPoint:ClearAnchorPoint() + controlPoint:SetAnchorPoint(self.parent.selfPoint) local regionData = controlPoint.regionData if regionData then if self.parent.anchorPerUnit == "UNITFRAME" then @@ -457,7 +458,7 @@ local centeredIndexerStart = { if maxIndex % 2 == 1 then return maxIndex else - return maxIndex > 0 and maxIndex - 1 or nil + return maxIndex > 0 and maxIndex - 1 or nil end end } @@ -506,7 +507,7 @@ local centeredIndexerNext = { } local function createAnchorPerUnitFunc(data) - local anchorer = anchorers[data.anchorPerUnit] or anchorers.NAMEPLATE or anchorers.UNITFRAME + local anchorer = anchorers[data.anchorPerUnit] or anchorers.NAMEPLATE return anchorer(data) end @@ -1065,8 +1066,10 @@ local function modify(parent, region, data) bottom = data.borderInset, }, }); - background:SetBackdropBorderColor(data.borderColor[1], data.borderColor[2], data.borderColor[3], data.borderColor[4]); - background:SetBackdropColor(data.backdropColor[1], data.backdropColor[2], data.backdropColor[3], data.backdropColor[4]); + background:SetBackdropBorderColor(data.borderColor[1], data.borderColor[2], + data.borderColor[3], data.borderColor[4]); + background:SetBackdropColor(data.backdropColor[1], data.backdropColor[2], + data.backdropColor[3], data.backdropColor[4]); background:ClearAllPoints(); background:SetPoint("bottomleft", region, "bottomleft", -1 * data.borderOffset, -1 * data.borderOffset) @@ -1368,13 +1371,13 @@ local function modify(parent, region, data) controlPoint:SetWidth(regionData.dimensions.width) controlPoint:SetHeight(regionData.dimensions.height) if (data.anchorFrameParent or data.anchorFrameParent == nil) - and (data.useAnchorPerUnit + and ( + data.useAnchorPerUnit or ( not data.useAnchorPerUnit - and not (data.anchorFrameType == "SCREEN" - or data.anchorFrameType == "UIPARENT" - or data.anchorFrameType == "MOUSE") - )) + and not (data.anchorFrameType == "SCREEN" or data.anchorFrameType == "UIPARENT" or data.anchorFrameType == "MOUSE") + ) + ) then local parent if frame == "" then diff --git a/WeakAuras/RegionTypes/Icon.lua b/WeakAuras/RegionTypes/Icon.lua index 86fa7e0..da1727c 100644 --- a/WeakAuras/RegionTypes/Icon.lua +++ b/WeakAuras/RegionTypes/Icon.lua @@ -121,11 +121,15 @@ local function GetTexCoord(region, texWidth, aspectRatio, xOffset, yOffset) local db = region.MSQGroup.db if db and not db.Disabled then usesMasque = true - region.currentCoord[1], region.currentCoord[2], region.currentCoord[3], region.currentCoord[4], region.currentCoord[5], region.currentCoord[6], region.currentCoord[7], region.currentCoord[8] = region.icon:GetTexCoord() + region.currentCoord[1], region.currentCoord[2], region.currentCoord[3], region.currentCoord[4], + region.currentCoord[5], region.currentCoord[6], region.currentCoord[7], region.currentCoord[8] + = region.icon:GetTexCoord() end end if (not usesMasque) then - region.currentCoord[1], region.currentCoord[2], region.currentCoord[3], region.currentCoord[4], region.currentCoord[5], region.currentCoord[6], region.currentCoord[7], region.currentCoord[8] = 0, 0, 0, 1, 1, 0, 1, 1; + region.currentCoord[1], region.currentCoord[2], region.currentCoord[3], region.currentCoord[4], + region.currentCoord[5], region.currentCoord[6], region.currentCoord[7], region.currentCoord[8] + = 0, 0, 0, 1, 1, 0, 1, 1; end local xRatio = aspectRatio < 1 and aspectRatio or 1; @@ -149,8 +153,7 @@ local function AnchorSubRegion(self, subRegion, anchorType, anchorPoint, selfPoi if anchorType == "area" then Private.regionPrototype.AnchorSubRegion(selfPoint == "region" and self or self.icon, - subRegion, anchorType, anchorPoint, - selfPoint, anchorXOffset, anchorYOffset) + subRegion, anchorType, anchorPoint, selfPoint, anchorXOffset, anchorYOffset) else subRegion:ClearAllPoints() anchorPoint = anchorPoint or "CENTER" @@ -313,7 +316,8 @@ local function create(parent, data) icon.SetTexture = setTexture --This section creates a unique frame id for the cooldown frame so that it can be created with a global reference - --The reason is so that WeakAuras cooldown frames can interact properly with OmniCC (i.e., put on its ignore list for timer overlays) + --The reason is so that WeakAuras cooldown frames can interact properly with OmniCC + -- (i.e., put on its ignore list for timer overlays) local id = data.id; local frameId = id:lower():gsub(" ", "_"); if(_G["WeakAurasCooldown"..frameId]) then @@ -465,13 +469,15 @@ local function modify(parent, region, data) if region.inverseDirection == inverse then return end + 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.inverseDirection == 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 @@ -481,6 +487,7 @@ local function modify(parent, region, data) cooldown.useCooldownModRate and cooldown.modRate or nil) end end + region:SetInverse(data.inverse) function region:Color(r, g, b, a) @@ -491,7 +498,8 @@ local function modify(parent, region, data) if (r or g or b) then a = a or 1; end - icon:SetVertexColor(region.color_anim_r or r, region.color_anim_g or g, region.color_anim_b or b, region.color_anim_a or a); + icon:SetVertexColor(region.color_anim_r or r, region.color_anim_g or g, + region.color_anim_b or b, region.color_anim_a or a) if region.button then region.button:SetAlpha(region.color_anim_a or a or 1); end diff --git a/WeakAuras/RegionTypes/RegionPrototype.lua b/WeakAuras/RegionTypes/RegionPrototype.lua index 5d5d0f8..ca9a4b3 100644 --- a/WeakAuras/RegionTypes/RegionPrototype.lua +++ b/WeakAuras/RegionTypes/RegionPrototype.lua @@ -482,7 +482,6 @@ local function UpdateProgressFromState(self, minMaxConfig, state, progressSource else max = duration end - self.minProgress, self.maxProgress = adjustMin, max self.progressType = "timed" self.duration = max - adjustMin @@ -520,6 +519,7 @@ local function UpdateProgressFromState(self, minMaxConfig, state, progressSource else max = duration end + self.minProgress, self.maxProgress = adjustMin, max self.progressType = "timed" self.duration = max - adjustMin @@ -703,6 +703,7 @@ function Private.regionPrototype.create(region) region.RunCode = RunCode; region.GlowExternal = GlowExternal; + region.ReAnchor = UpdatePosition; region.SetAnchor = SetAnchor; region.SetOffset = SetOffset; region.SetXOffset = SetXOffset; @@ -778,17 +779,22 @@ function Private.regionPrototype.AddMinMaxProgressSource(hasProgressSource, regi end end end + function Private.regionPrototype.modify(parent, region, data) region.state = nil region.states = nil region.subRegionEvents:ClearSubscribers() region.subRegionEvents:ClearCallbacks() Private.FrameTick:RemoveSubscriber("Tick", region) + local defaultsForRegion = Private.regionTypes[data.regionType] and Private.regionTypes[data.regionType].default; + if region.SetRegionAlpha then region:SetRegionAlpha(data.alpha) end + local hasProgressSource = defaultsForRegion and defaultsForRegion.progressSource + Private.regionPrototype.AddMinMaxProgressSource(hasProgressSource, region, data, data) region:SetOffset(data.xOffset or 0, data.yOffset or 0); diff --git a/WeakAuras/RegionTypes/SmoothStatusBarMixin.lua b/WeakAuras/RegionTypes/SmoothStatusBarMixin.lua index 1b7fdef..6e38532 100644 --- a/WeakAuras/RegionTypes/SmoothStatusBarMixin.lua +++ b/WeakAuras/RegionTypes/SmoothStatusBarMixin.lua @@ -7,26 +7,26 @@ local AddonName, Private = ... local g_updatingBars = {}; local function IsCloseEnough(bar, newValue, targetValue) - local min, max = bar:GetMinMaxValues(); - local range = max - min; - if range > 0.0 then - return math.abs((newValue - targetValue) / range) < 0.00001; - end + local min, max = bar:GetMinMaxValues(); + local range = max - min; + if range > 0.0 then + return math.abs((newValue - targetValue) / range) < 0.00001; + end - return true; + return true; end local function ProcessSmoothStatusBars(self, elapsed) - for bar, targetValue in pairs(g_updatingBars) do - local newValue = FrameDeltaLerp(bar:GetValue(), targetValue, 0.25, elapsed); + for bar, targetValue in pairs(g_updatingBars) do + local newValue = FrameDeltaLerp(bar:GetValue(), targetValue, 0.25, elapsed); - if IsCloseEnough(bar, newValue, targetValue) then - g_updatingBars[bar] = nil; - bar:SetValue(targetValue); - else - bar:SetValue(newValue); - end - end + if IsCloseEnough(bar, newValue, targetValue) then + g_updatingBars[bar] = nil; + bar:SetValue(targetValue); + else + bar:SetValue(newValue); + end + end end CreateFrame("Frame"):SetScript("OnUpdate", ProcessSmoothStatusBars); @@ -34,32 +34,32 @@ CreateFrame("Frame"):SetScript("OnUpdate", ProcessSmoothStatusBars); Private.SmoothStatusBarMixin = {}; function Private.SmoothStatusBarMixin:ResetSmoothedValue(value) --If nil, tries to set to the last target value - local targetValue = g_updatingBars[self]; - if targetValue then - g_updatingBars[self] = nil; - self:SetValue(value or targetValue); - elseif value then - self:SetValue(value); - end + local targetValue = g_updatingBars[self]; + if targetValue then + g_updatingBars[self] = nil; + self:SetValue(value or targetValue); + elseif value then + self:SetValue(value); + end end function Private.SmoothStatusBarMixin:SetSmoothedValue(value) - g_updatingBars[self] = value; + g_updatingBars[self] = value; end function Private.SmoothStatusBarMixin:SetMinMaxSmoothedValue(min, max) - self:SetMinMaxValues(min, max); + self:SetMinMaxValues(min, max); - local targetValue = g_updatingBars[self]; - if targetValue then - local ratio = 1; - if max ~= 0 and self.lastSmoothedMax and self.lastSmoothedMax ~= 0 then - ratio = max / self.lastSmoothedMax; - end + local targetValue = g_updatingBars[self]; + if targetValue then + local ratio = 1; + if max ~= 0 and self.lastSmoothedMax and self.lastSmoothedMax ~= 0 then + ratio = max / self.lastSmoothedMax; + end - g_updatingBars[self] = targetValue * ratio; - end + g_updatingBars[self] = targetValue * ratio; + end - self.lastSmoothedMin = min; - self.lastSmoothedMax = max; + self.lastSmoothedMin = min; + self.lastSmoothedMax = max; end diff --git a/WeakAuras/RegionTypes/Text.lua b/WeakAuras/RegionTypes/Text.lua index ffe810d..d40c5fd 100644 --- a/WeakAuras/RegionTypes/Text.lua +++ b/WeakAuras/RegionTypes/Text.lua @@ -74,20 +74,15 @@ local function modify(parent, region, data) local text = region.text; local fontPath = SharedMedia:Fetch("font", data.font); + text:SetFont(fontPath, data.fontSize < 33 and data.fontSize or 33, data.outline == "None" and "" or data.outline); if not text:GetFont() and fontPath then -- workaround font not loading correctly local objectName = "WeakAuras-Font-" .. data.font local fontObject = _G[objectName] or CreateFont(objectName) fontObject:SetFont(fontPath, data.fontSize < 33 and data.fontSize or 33, data.outline == "None" and "" or data.outline) text:SetFontObject(fontObject) end - text:SetFont(fontPath, data.fontSize < 33 and data.fontSize or 33, data.outline); if not text:GetFont() then -- Font invalid, set the font but keep the setting - text:SetFont(STANDARD_TEXT_FONT, data.fontSize <= 33 and data.fontSize or 33, data.outline); - end - text:SetTextHeight(data.fontSize); - if text:GetFont() then - text:SetText("") - text:SetText(WeakAuras.ReplaceRaidMarkerSymbols(data.displayText)); + text:SetFont(STANDARD_TEXT_FONT, data.fontSize < 33 and data.fontSize or 33, data.outline == "None" and "" or data.outline); end text:SetJustifyH(data.justify); @@ -116,6 +111,7 @@ local function modify(parent, region, data) region.tooltipFrame:EnableMouse(false); end + text:SetTextHeight(data.fontSize); text:SetShadowColor(unpack(data.shadowColor)) text:SetShadowOffset(data.shadowXOffset, data.shadowYOffset) @@ -333,7 +329,6 @@ local function modify(parent, region, data) region.displayText = data.displayText region:ConfigureTextUpdate() region:ConfigureSubscribers() - Private.regionPrototype.modifyFinish(parent, region, data); end @@ -349,8 +344,7 @@ local function fallbackmodify(parent, region, data) Private.regionPrototype.modify(parent, region, data); local text = region.text; - text:SetFont(STANDARD_TEXT_FONT, data.fontSize < 33 and data.fontSize or 33, data.outline and "OUTLINE" or nil); - text:SetTextHeight(data.fontSize); + text:SetFont(STANDARD_TEXT_FONT, data.fontSize, data.outline and "OUTLINE" or nil); if text:GetFont() then text:SetText(WeakAuras.L["Region type %s not supported"]:format(data.regionType)); end diff --git a/WeakAuras/SubRegionTypes/Background.lua b/WeakAuras/SubRegionTypes/Background.lua index 229427f..214394e 100644 --- a/WeakAuras/SubRegionTypes/Background.lua +++ b/WeakAuras/SubRegionTypes/Background.lua @@ -3,54 +3,56 @@ local AddonName, Private = ... local L = WeakAuras.L; do - local function subSupports(regionType) - return regionType ~= "group" and regionType ~= "dynamicgroup" - end + local function subSupports(regionType) + return regionType ~= "group" and regionType ~= "dynamicgroup" + end - local function noop() - end + local function noop() + end - local function subSetFrameLevel(self, level) - self.parent:SetFrameLevel(level) - end + local function subSetFrameLevel(self, level) + self.parent:SetFrameLevel(level) + end - local function subCreate() - return { Update = noop, SetFrameLevel = subSetFrameLevel} - end + local function subCreate() + return { Update = noop, SetFrameLevel = subSetFrameLevel} + end - local function subModify(parent, region) - region.parent = parent - end + local function subModify(parent, region) + region.parent = parent + end - WeakAuras.RegisterSubRegionType("subbackground", L["Background"], subSupports, subCreate, subModify, noop, noop, {}, nil, {}, false); + WeakAuras.RegisterSubRegionType("subbackground", L["Background"], subSupports, subCreate, subModify, + noop, noop, {}, nil, {}, false) end -- Foreground for aurabar do - local function subSupports(regionType) - return regionType == "aurabar" - end + local function subSupports(regionType) + return regionType == "aurabar" + end - local function noop() - end + local function noop() + end - local function subSetFrameLevel(self, level) - if self.parent.bar then - self.parent.bar:SetFrameLevel(level) - end - if self.parent.iconFrame then - self.parent.iconFrame:SetFrameLevel(level) - end + local function subSetFrameLevel(self, level) + if self.parent.bar then + self.parent.bar:SetFrameLevel(level) end - - local function subCreate() - return { Update = noop, SetFrameLevel = subSetFrameLevel} + if self.parent.iconFrame then + self.parent.iconFrame:SetFrameLevel(level) end + end - local function subModify(parent, region) - region.parent = parent - end + local function subCreate() + return { Update = noop, SetFrameLevel = subSetFrameLevel} + end - WeakAuras.RegisterSubRegionType("subforeground", L["Foreground"], subSupports, subCreate, subModify, noop, noop, {}, nil, {}, false); + local function subModify(parent, region) + region.parent = parent + end + + WeakAuras.RegisterSubRegionType("subforeground", L["Foreground"], subSupports, subCreate, subModify, + noop, noop, {}, nil, {}, false) end diff --git a/WeakAuras/SubRegionTypes/Border.lua b/WeakAuras/SubRegionTypes/Border.lua index dab509f..aaa45ff 100644 --- a/WeakAuras/SubRegionTypes/Border.lua +++ b/WeakAuras/SubRegionTypes/Border.lua @@ -34,7 +34,8 @@ local properties = { local function create() - return CreateFrame("Frame", nil, UIParent) + local region = CreateFrame("Frame", nil, UIParent) + return region end local function onAcquire(subRegion) @@ -55,7 +56,8 @@ local function modify(parent, region, parentData, data, first) edgeSize = data.border_size, bgFile = nil, }) - region:SetBackdropBorderColor(data.border_color[1], data.border_color[2], data.border_color[3], data.border_color[4]) + region:SetBackdropBorderColor(data.border_color[1], data.border_color[2], + data.border_color[3], data.border_color[4]) region:SetBackdropColor(0, 0, 0, 0) end @@ -83,10 +85,11 @@ end local function supports(regionType) return regionType == "texture" - or regionType == "progresstexture" - or regionType == "icon" - or regionType == "aurabar" - or regionType == "empty" + or regionType == "progresstexture" + or regionType == "icon" + or regionType == "aurabar" + or regionType == "empty" end -WeakAuras.RegisterSubRegionType("subborder", L["Border"], supports, create, modify, onAcquire, onRelease, default, nil, properties); +WeakAuras.RegisterSubRegionType("subborder", L["Border"], supports, create, modify, onAcquire, onRelease, + default, nil, properties) diff --git a/WeakAuras/SubRegionTypes/Glow.lua b/WeakAuras/SubRegionTypes/Glow.lua index be08c7b..01989c7 100644 --- a/WeakAuras/SubRegionTypes/Glow.lua +++ b/WeakAuras/SubRegionTypes/Glow.lua @@ -2,7 +2,8 @@ if not WeakAuras.IsLibsOK() then return end local AddonName, Private = ... local LCG = LibStub("LibCustomGlow-1.0") -local MSQ = LibStub("Masque", true); + +local MSQ = LibStub("Masque", true) local L = WeakAuras.L local default = function(parentType) @@ -306,6 +307,9 @@ end local function onRelease(subRegion) subRegion.glowType = nil + if subRegion.glow then + subRegion:SetVisible(false) + end subRegion:Hide() subRegion:ClearAllPoints() subRegion:SetParent(UIParent) @@ -411,4 +415,5 @@ local function addDefaultsForNewAura(data) end end -WeakAuras.RegisterSubRegionType("subglow", L["Glow"], supports, create, modify, onAcquire, onRelease, default, addDefaultsForNewAura, properties); +WeakAuras.RegisterSubRegionType("subglow", L["Glow"], supports, create, modify, onAcquire, onRelease, + default, addDefaultsForNewAura, properties) diff --git a/WeakAuras/SubRegionTypes/Model.lua b/WeakAuras/SubRegionTypes/Model.lua index 37454fa..d3d2e17 100644 --- a/WeakAuras/SubRegionTypes/Model.lua +++ b/WeakAuras/SubRegionTypes/Model.lua @@ -173,8 +173,6 @@ local function onRelease(subRegion) subRegion:Hide() end - - local function modify(parent, region, parentData, data, first) if region.model then ReleaseModel(region.model) @@ -204,6 +202,7 @@ local function modify(parent, region, parentData, data, first) extra_height = data.extra_height or 0 end + region:ClearAllPoints() region:SetPoint("TOPLEFT", anchor ,"TOPLEFT", -extra_width/2, extra_height/2) region:SetPoint("BOTTOMRIGHT", anchor ,"BOTTOMRIGHT", extra_width/2, -extra_height/2) diff --git a/WeakAuras/SubRegionTypes/Tick.lua b/WeakAuras/SubRegionTypes/Tick.lua index a70d28d..9f14b75 100644 --- a/WeakAuras/SubRegionTypes/Tick.lua +++ b/WeakAuras/SubRegionTypes/Tick.lua @@ -228,6 +228,7 @@ local funcs = { end end end + if requiresFrameTick then if not self.FrameTick then self.FrameTick = self.UpdateTickPlacement @@ -263,6 +264,7 @@ local funcs = { local minValue, maxValue = self.parent:GetMinMaxProgress() local valueRange = maxValue - minValue local inverse = self.inverse_direction + if self.parent.inverse then inverse = not inverse end @@ -444,11 +446,14 @@ local funcs = { self.use_texture = use self:UpdateTexture() end, + AnchorSubRegion = function(self, subRegion, anchorType, anchorPoint, subRegionPoint, anchorXOffset, anchorYOffset) subRegion:ClearAllPoints() + if anchorType == "point" then local xOffset = anchorXOffset or 0 local yOffset = anchorYOffset or 0 + subRegionPoint = Private.point_types[subRegionPoint] and subRegionPoint or "CENTER" local tickIndex = tonumber(anchorPoint:sub(6)) local anchorTo = tickIndex and self.ticks[tickIndex] or nil diff --git a/WeakAuras/Transmission.lua b/WeakAuras/Transmission.lua index 13ae159..066f242 100644 --- a/WeakAuras/Transmission.lua +++ b/WeakAuras/Transmission.lua @@ -132,7 +132,8 @@ function CompressDisplay(data, version) end local copiedData = CopyTable(data) - local non_transmissable_fields = version >= 2000 and Private.non_transmissable_fields_v2000 or Private.non_transmissable_fields + local non_transmissable_fields = version >= 2000 and Private.non_transmissable_fields_v2000 + or Private.non_transmissable_fields stripNonTransmissableFields(copiedData, non_transmissable_fields) copiedData.tocversion = WeakAuras.BuildInfo return copiedData; @@ -492,7 +493,7 @@ function ShowTooltip(lines) ItemRefTooltip:Show() end -local delayedImport = CreateFrame("FRAME") +local delayedImport = CreateFrame("Frame") local function ImportNow(data, children, target, linkedAuras, sender, callbackFunc) if InCombatLockdown() then diff --git a/WeakAuras/Types.lua b/WeakAuras/Types.lua index 02a870a..35377c2 100644 --- a/WeakAuras/Types.lua +++ b/WeakAuras/Types.lua @@ -11,7 +11,7 @@ local GetNumShapeshiftForms, GetShapeshiftFormInfo = GetNumShapeshiftForms, GetS local function WA_GetClassColor(classFilename) local color = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[classFilename] - if color and color.colorStr then + if color then return color.colorStr end @@ -2378,7 +2378,7 @@ Private.anim_finish_preset_types = { spiral = L["Spiral"], bounceDecay = L["Bounce"], starShakeDecay = L["Star Shake"], -}; +} Private.chat_message_types = { CHAT_MSG_BATTLEGROUND = L["Battleground"], @@ -2517,7 +2517,6 @@ LSM:Register("sound", "Voice: Switch", "Interface\\AddOns\\WeakAuras\\Media\\Sou LSM:Register("sound", "Voice: Taunt", "Interface\\AddOns\\WeakAuras\\Media\\Sounds\\Taunt.ogg") LSM:Register("sound", "Voice: Triangle", "Interface\\AddOns\\WeakAuras\\Media\\Sounds\\Triangle.ogg") - local PowerAurasSoundPath = "Interface\\Addons\\WeakAuras\\PowerAurasMedia\\Sounds\\" LSM:Register("sound", "Aggro", PowerAurasSoundPath.."aggro.ogg") LSM:Register("sound", "Arrow Swoosh", PowerAurasSoundPath.."Arrow_swoosh.ogg") @@ -2612,7 +2611,6 @@ LSM:Register("font", "PT Sans Narrow Bold", "Interface\\Addons\\WeakAuras\\Media -- register plain white border LSM:Register("border", "Square Full White", [[Interface\AddOns\WeakAuras\Media\Textures\Square_FullWhite.tga]]) --- LSM:Register("statusbar", "Clean", [[Interface\AddOns\WeakAuras\Media\Textures\Statusbar_Clean]]) LSM:Register("statusbar", "Stripes", [[Interface\AddOns\WeakAuras\Media\Textures\Statusbar_Stripes]]) LSM:Register("statusbar", "Thick Stripes", [[Interface\AddOns\WeakAuras\Media\Textures\Statusbar_Stripes_Thick]]) diff --git a/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasToolbarButton.lua b/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasToolbarButton.lua index 7a7ba35..2f6864d 100644 --- a/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasToolbarButton.lua +++ b/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasToolbarButton.lua @@ -57,7 +57,7 @@ local methods = { ["SetText"] = function(self, text) self.text:SetText(text) if text ~= "" then - self:SetWidth(self.text:GetStringWidth() + 24) + self:SetWidth(self.text:GetStringWidth() + 28) else self:SetWidth(16) end