diff --git a/WeakAuras/Animations.lua b/WeakAuras/Animations.lua index 9c8db06..b234022 100644 --- a/WeakAuras/Animations.lua +++ b/WeakAuras/Animations.lua @@ -134,7 +134,10 @@ local function UpdateAnimations() if not ok then errorHandler(r) else - anim.region:ColorAnim(r, g, b, a); + local success = pcall(anim.region.ColorAnim, errorHandler, anim.region, r, g, b, a) + if not success then + Private.GetErrorHandlerId(anim.region.id, "Custom Color") + end end end Private.ActivateAuraEnvironment(nil); diff --git a/WeakAuras/AuraEnvironment.lua b/WeakAuras/AuraEnvironment.lua index a00fb59..dd3d8d7 100644 --- a/WeakAuras/AuraEnvironment.lua +++ b/WeakAuras/AuraEnvironment.lua @@ -493,7 +493,7 @@ local exec_env_custom = setmetatable({}, return DebugPrint elseif blockedFunctions[k] then blocked(k) - return function() end + return function(_) end elseif blockedTables[k] then blocked(k) return {} @@ -538,7 +538,7 @@ local exec_env_builtin = setmetatable({}, return PrivateForBuiltIn elseif blockedFunctions[k] then blocked(k) - return function() end + return function(_) end elseif blockedTables[k] then blocked(k) return {} diff --git a/WeakAuras/BuffTrigger2.lua b/WeakAuras/BuffTrigger2.lua index 97630a0..728d568 100644 --- a/WeakAuras/BuffTrigger2.lua +++ b/WeakAuras/BuffTrigger2.lua @@ -2180,7 +2180,7 @@ local function createScanFunc(trigger) if use_tooltip and trigger.tooltip_operator and trigger.tooltip then if trigger.tooltip_operator == "==" then local ret2 = [[ - if not matchData.tooltip or not matchData.tooltip == %s then + if not matchData.tooltip or matchData.tooltip ~= %s then return false end ]] diff --git a/WeakAuras/GenericTrigger.lua b/WeakAuras/GenericTrigger.lua index d1324f4..32867ba 100644 --- a/WeakAuras/GenericTrigger.lua +++ b/WeakAuras/GenericTrigger.lua @@ -560,6 +560,7 @@ function Private.ActivateEvent(id, triggernum, data, state, errorHandler) arg2 = type(arg2) == "number" and arg2 or 0; end + if (state.inverse ~= inverse) then state.inverse = inverse; changed = true; @@ -601,6 +602,11 @@ function Private.ActivateEvent(id, triggernum, data, state, errorHandler) if (state.duration ~= arg1) then state.duration = arg1; end + -- The Icon's SetCooldown requires that the **startTime** is positive, so ensure that + -- the expirationTime is bigger than the duration + if arg2 <= arg1 then + arg2 = arg1 + end if (state.expirationTime ~= arg2) then state.expirationTime = arg2; changed = true; @@ -2087,6 +2093,7 @@ do function Private.InitCooldownReady() cdReadyFrame = CreateFrame("Frame"); + cdReadyFrame.inWorld = 0 Private.frames["Cooldown Trigger Handler"] = cdReadyFrame cdReadyFrame:RegisterEvent("RUNE_POWER_UPDATE"); cdReadyFrame:RegisterEvent("RUNE_TYPE_UPDATE"); @@ -2100,7 +2107,24 @@ do cdReadyFrame:RegisterEvent("ACTIONBAR_UPDATE_COOLDOWN"); cdReadyFrame:RegisterEvent("SPELLS_CHANGED"); cdReadyFrame:RegisterEvent("PLAYER_ENTERING_WORLD"); - cdReadyFrame:SetScript("OnEvent", function(self, event, ...) + cdReadyFrame:RegisterEvent("PLAYER_LEAVING_WORLD"); + cdReadyFrame.HandleEvent = function(self, event, ...) + if (event == "PLAYER_ENTERING_WORLD") then + cdReadyFrame.inWorld = GetTime() + end + if (event == "PLAYER_LEAVING_WORLD") then + cdReadyFrame.inWorld = nil + end + if not cdReadyFrame.inWorld then + return + end + + if GetTime() - cdReadyFrame.inWorld < 2 then + cdReadyFrame:SetScript("OnUpdate", cdReadyFrame.HandleEvent) + return + end + cdReadyFrame:SetScript("OnUpdate", nil) + Private.StartProfileSystem("generictrigger cd tracking"); if(event == "SPELL_UPDATE_COOLDOWN" or event == "RUNE_POWER_UPDATE" or event == "RUNE_TYPE_UPDATE" or event == "ACTIONBAR_UPDATE_COOLDOWN" @@ -2126,7 +2150,8 @@ do Private.CheckItemSlotCooldowns(); end Private.StopProfileSystem("generictrigger cd tracking"); - end); + end + cdReadyFrame:SetScript("OnEvent", cdReadyFrame.HandleEvent) end function WeakAuras.GetRuneCooldown(id) diff --git a/WeakAuras/Init.lua b/WeakAuras/Init.lua index 2cb6bb3..42ae8e9 100644 --- a/WeakAuras/Init.lua +++ b/WeakAuras/Init.lua @@ -93,22 +93,22 @@ if not WeakAuras.IsLibsOK() then end -- These function stubs are defined here to reduce the number of errors that occur if WeakAuras.lua fails to compile -function WeakAuras.RegisterRegionType() +function WeakAuras.RegisterRegionType(_, _, _ ,_) end -function WeakAuras.RegisterRegionOptions() +function WeakAuras.RegisterRegionOptions(_, _ , _ ,_) end -function Private.StartProfileSystem() +function Private.StartProfileSystem(_) end -function Private.StartProfileAura() +function Private.StartProfileAura(_) end -function Private.StopProfileSystem() +function Private.StopProfileSystem(_) end -function Private.StopProfileAura() +function Private.StopProfileAura(_) end function Private.StartProfileUID() @@ -120,7 +120,7 @@ end Private.ExecEnv = {} -- If WeakAuras shuts down due to being installed on the wrong target, keep the bindings from erroring -function WeakAuras.StartProfile() +function WeakAuras.StartProfile(_) end function WeakAuras.StopProfile() diff --git a/WeakAuras/RegionTypes/AuraBar.lua b/WeakAuras/RegionTypes/AuraBar.lua index 9dddf53..fae8774 100644 --- a/WeakAuras/RegionTypes/AuraBar.lua +++ b/WeakAuras/RegionTypes/AuraBar.lua @@ -1014,8 +1014,8 @@ local function create(parent) local bar = CreateFrame("Frame", nil, region); WeakAuras.Mixin(bar, SmoothStatusBarMixin); local fg = bar:CreateTexture(nil, "BORDER"); - local bg = bar:CreateTexture(nil, "BACKGROUND"); - bg:SetAllPoints(); + local bg = region:CreateTexture(nil, "BACKGROUND"); + bg:SetAllPoints(bar); local fgFrame = CreateFrame("Frame", nil, bar) local spark = bar:CreateTexture(nil, "ARTWORK"); bar.fg = fg; diff --git a/WeakAuras/RegionTypes/DynamicGroup.lua b/WeakAuras/RegionTypes/DynamicGroup.lua index 1f0dd06..de646a5 100644 --- a/WeakAuras/RegionTypes/DynamicGroup.lua +++ b/WeakAuras/RegionTypes/DynamicGroup.lua @@ -36,6 +36,7 @@ local default = { useLimit = false, limit = 5, gridType = "RD", + centerType = "LR", gridWidth = 5, rowSpace = 1, columnSpace = 1 @@ -411,6 +412,76 @@ local anchorers = { end } +-- Names are based on the Left->Right layout, +local centeredIndexerStart = { + -- Left to right, e.g: 1 2 3 4 + ["LR"] = function(maxIndex) + return maxIndex > 0 and 1 or nil + end, + ["RL"] = function(maxIndex) + return maxIndex > 0 and maxIndex or nil + end, + -- Center -> Left -> Right, e.g: 4 2 1 3 + ["CLR"] = function(maxIndex) + if maxIndex >= 3 then + return maxIndex - maxIndex % 2 + else + return maxIndex + end + end, + -- Center -> Right -> Left, e.g: 3 1 2 4 + ["CRL"] = function(maxIndex) + if maxIndex % 2 == 1 then + return maxIndex + else + return maxIndex - 1 + end + end +} + +local centeredIndexerNext = { + ["LR"] = function(index, maxIndex) + index = index + 1 + return index <= maxIndex and index or nil + end, + ["RL"] = function(index, maxIndex) + index = index - 1 + return index > 0 and index or nil + end, + ["CLR"] = function(index, maxIndex) + -- Center -> Left -> Right + -- So even -> odd + if index % 2 == 0 then + index = index - 2 + if index == 0 then + index = 1 + end + else + index = index + 2 + end + if index > maxIndex then + return nil + end + return index + end, + ["CRL"] = function(index, maxIndex) + -- Center -> Right -> Left + -- So odd -> even + if index % 2 == 1 then + index = index - 2 + if index == -1 then + index = 2 + end + else + index = index + 2 + end + if index > maxIndex then + return nil + end + return index + end, +} + local function createAnchorPerUnitFunc(data) local anchorer = anchorers[data.anchorPerUnit] or anchorers.NAMEPLATE or anchorers.UNITFRAME return anchorer(data) @@ -539,6 +610,8 @@ local growers = { local limit = data.useLimit and data.limit or math.huge local midX, midY = 0, 0 local anchorPerUnitFunc = data.useAnchorPerUnit and createAnchorPerUnitFunc(data) + local FirstIndex = centeredIndexerStart[data.centerType] + local NextIndex = centeredIndexerNext[data.centerType] return function(newPositions, activeRegions) local frames = {} if anchorPerUnitFunc then @@ -555,13 +628,14 @@ local growers = { end local x, y = midX - totalWidth/2, midY - (stagger * (numVisible - 1)/2) newPositions[frame] = {} - for i, regionData in ipairs(regionDatas) do - if i <= numVisible then - x = x + (regionData.dimensions.width) / 2 - newPositions[frame][regionData] = { x, y, true } - x = x + (regionData.dimensions.width) / 2 + space - y = y + stagger - end + local i = FirstIndex(numVisible) + while i do + local regionData = regionDatas[i] + x = x + (regionData.dimensions.width) / 2 + newPositions[frame][regionData] = { x, y, true } + x = x + (regionData.dimensions.width) / 2 + space + y = y + stagger + i = NextIndex(i, numVisible) end end end @@ -572,6 +646,8 @@ local growers = { local limit = data.useLimit and data.limit or math.huge local midX, midY = 0, 0 local anchorPerUnitFunc = data.useAnchorPerUnit and createAnchorPerUnitFunc(data) + local FirstIndex = centeredIndexerStart[data.centerType] + local NextIndex = centeredIndexerNext[data.centerType] return function(newPositions, activeRegions) local frames = {} if anchorPerUnitFunc then @@ -588,13 +664,14 @@ local growers = { end local x, y = midX - (stagger * (numVisible - 1)/2), midY - totalHeight/2 newPositions[frame] = {} - for i, regionData in ipairs(regionDatas) do - if i <= numVisible then - y = y + (regionData.dimensions.height) / 2 - newPositions[frame][regionData] = { x, y, true } - x = x + stagger - y = y + (regionData.dimensions.height) / 2 + space - end + local i = FirstIndex(numVisible) + while i do + local regionData = regionDatas[i] + y = y + (regionData.dimensions.height) / 2 + newPositions[frame][regionData] = { x, y, true } + x = x + stagger + y = y + (regionData.dimensions.height) / 2 + space + i = NextIndex(i, numVisible) end end end diff --git a/WeakAuras/RegionTypes/Icon.lua b/WeakAuras/RegionTypes/Icon.lua index 56dee65..c2e23f5 100644 --- a/WeakAuras/RegionTypes/Icon.lua +++ b/WeakAuras/RegionTypes/Icon.lua @@ -109,7 +109,9 @@ local function GetProperties(data) return result end -local function GetTexCoord(region, texWidth, aspectRatio) +local function GetTexCoord(region, texWidth, aspectRatio, xOffset, yOffset) + xOffset = xOffset or 0 + yOffset = yOffset or 0 region.currentCoord = region.currentCoord or {} local usesMasque = false if region.MSQGroup then @@ -126,8 +128,11 @@ local function GetTexCoord(region, texWidth, aspectRatio) local xRatio = aspectRatio < 1 and aspectRatio or 1; local yRatio = aspectRatio > 1 and 1 / aspectRatio or 1; for i, coord in ipairs(region.currentCoord) do - local aspectRatio = (i % 2 == 1) and xRatio or yRatio; - region.currentCoord[i] = (coord - 0.5) * texWidth * aspectRatio + 0.5; + if(i % 2 == 1) then + region.currentCoord[i] = (coord - 0.5) * texWidth * xRatio + 0.5 - xOffset; + else + region.currentCoord[i] = (coord - 0.5) * texWidth * yRatio + 0.5 - yOffset; + end end return unpack(region.currentCoord) @@ -401,7 +406,8 @@ local function modify(parent, region, data) end end - local ulx, uly, llx, lly, urx, ury, lrx, lry = GetTexCoord(region, texWidth, aspectRatio) + local ulx, uly, llx, lly, urx, ury, lrx, lry + = GetTexCoord(region, texWidth, aspectRatio, region.texXOffset, region.texYOffset and -region.texYOffset) if(mirror_h) then if(mirror_v) then @@ -424,6 +430,8 @@ local function modify(parent, region, data) region.scaley = 1; region.keepAspectRatio = data.keepAspectRatio; region.zoom = data.zoom; + region.texXOffset = data.texXOffset + region.texYOffset = data.texYOffset region:UpdateSize() icon:SetDesaturated(data.desaturate); diff --git a/WeakAuras/Types.lua b/WeakAuras/Types.lua index f6a1629..b9c5234 100644 --- a/WeakAuras/Types.lua +++ b/WeakAuras/Types.lua @@ -1833,6 +1833,20 @@ Private.grid_types = { VH = L["Centered Vertical, then Centered Horizontal"], } +Private.centered_types_h = { + LR = L["Left to Right"], + RL = L["Right to Left"], + CLR =L["Center, then alternating left and right"], + CRL = L["Center, then alternating right and left"] +} + +Private.centered_types_v = { + LR = L["Bottom to Top"], + RL = L["Top to Bottom"], + CLR =L["Center, then alternating bottom and top"], + CRL = L["Center, then alternating top and bottom"] +} + Private.text_rotate_types = { ["LEFT"] = L["Left"], ["NONE"] = L["None"], diff --git a/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasDisplayButton.lua b/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasDisplayButton.lua index 0abdf48..41e4da4 100644 --- a/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasDisplayButton.lua +++ b/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasDisplayButton.lua @@ -5,7 +5,7 @@ local tinsert, tremove, wipe = table.insert, table.remove, wipe local select, pairs, type, unpack = select, pairs, type, unpack local error = error -local Type, Version = "WeakAurasDisplayButton", 59 +local Type, Version = "WeakAurasDisplayButton", 60 local AceGUI = LibStub and LibStub("AceGUI-3.0", true) if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end diff --git a/WeakAurasOptions/CommonOptions.lua b/WeakAurasOptions/CommonOptions.lua index 868fcdb..ee48941 100644 --- a/WeakAurasOptions/CommonOptions.lua +++ b/WeakAurasOptions/CommonOptions.lua @@ -143,7 +143,9 @@ local function addCollapsibleHeader(options, key, input, order, isGroupTab) if notcollapsable then return "Interface\\AddOns\\WeakAuras\\Media\\Textures\\bullet1", 18, 18 else - return isCollapsed() and "Interface\\AddOns\\WeakAuras\\Media\\Textures\\expand" or "Interface\\AddOns\\WeakAuras\\Media\\Textures\\collapse", 18, 18 + return isCollapsed() and "Interface\\AddOns\\WeakAuras\\Media\\Textures\\expand" + or "Interface\\AddOns\\WeakAuras\\Media\\Textures\\collapse", + 18, 18 end end, control = "WeakAurasExpand", @@ -1248,8 +1250,10 @@ local function PositionOptions(id, data, _, hideWidthHeight, disableSelfPoint, g }, }; - OptionsPrivate.commonOptions.AddCodeOption(positionOptions, data, L["Custom Anchor"], "custom_anchor", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#custom-anchor-function", - 71.5, function() return not(data.anchorFrameType == "CUSTOM" and not IsParentDynamicGroup()) end, {"customAnchor"}, false, { setOnParent = group }) + OptionsPrivate.commonOptions.AddCodeOption(positionOptions, data, L["Custom Anchor"], "custom_anchor", + "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#custom-anchor-function", + 71.5, function() return not(data.anchorFrameType == "CUSTOM" and not IsParentDynamicGroup()) end, + {"customAnchor"}, false, { setOnParent = group }) return positionOptions; end @@ -1380,7 +1384,8 @@ local function AddCodeOption(args, data, name, prefix, url, order, hiddenFunc, p tinsert(options.extraFunctions, 1, { buttonLabel = L["Expand"], func = function() - OptionsPrivate.OpenTextEditor(OptionsPrivate.GetPickedDisplay(), path, encloseInFunction, options.multipath, options.reloadOptions, options.setOnParent, url, options.validator) + OptionsPrivate.OpenTextEditor(OptionsPrivate.GetPickedDisplay(), path, encloseInFunction, options.multipath, + options.reloadOptions, options.setOnParent, url, options.validator) end }); diff --git a/WeakAurasOptions/RegionOptions/DynamicGroup.lua b/WeakAurasOptions/RegionOptions/DynamicGroup.lua index 856b9a7..748d23e 100644 --- a/WeakAurasOptions/RegionOptions/DynamicGroup.lua +++ b/WeakAurasOptions/RegionOptions/DynamicGroup.lua @@ -206,6 +206,20 @@ local function createOptions(id, data) OptionsPrivate.ResetMoverSizer() end, }, + centerType = { + type = "select", + width = WeakAuras.normalWidth, + name = L["Aura Order"], + order = 3, + values = function() + if data.grow == "HORIZONTAL" then + return OptionsPrivate.Private.centered_types_h + else + return OptionsPrivate.Private.centered_types_v + end + end, + hidden = function() return data.grow ~= "HORIZONTAL" and data.grow ~= "VERTICAL" end, + }, -- circle grow options constantFactor = { type = "select", diff --git a/WeakAurasOptions/RegionOptions/Group.lua b/WeakAurasOptions/RegionOptions/Group.lua index 641371a..be6f75f 100644 --- a/WeakAurasOptions/RegionOptions/Group.lua +++ b/WeakAurasOptions/RegionOptions/Group.lua @@ -704,4 +704,5 @@ local function createIcon() end -- Register new region type options with WeakAuras -WeakAuras.RegisterRegionOptions("group", createOptions, createIcon, L["Group"], createThumbnail, modifyThumbnail, L["Controls the positioning and configuration of multiple displays at the same time"]); +WeakAuras.RegisterRegionOptions("group", createOptions, createIcon, L["Group"], createThumbnail, modifyThumbnail, + L["Controls the positioning and configuration of multiple displays at the same time"]) diff --git a/WeakAurasOptions/RegionOptions/Icon.lua b/WeakAurasOptions/RegionOptions/Icon.lua index 538cd95..7709aad 100644 --- a/WeakAurasOptions/RegionOptions/Icon.lua +++ b/WeakAurasOptions/RegionOptions/Icon.lua @@ -94,6 +94,12 @@ local function createOptions(id, data) line = L["%s Keep Aspect Ratio"]:format(line) changed = true end + if data.texXOffset and data.texXOffset ~= 0 then + line = L["%s X offset by %d"]:format(line, data.texXOffset) + end + if data.texYOffset and data.texYOffset ~= 0 then + line = L["%s Y offset by %d"]:format(line, data.texYOffset) + end if not changed then line = L["%s Default Alpha, Zoom, Icon Inset, Aspect Ratio"]:format(line) end @@ -153,12 +159,41 @@ local function createOptions(id, data) order = 7.05, hidden = hiddenIconExtra, }, + texXOffset = { + type = "range", + control = "WeakAurasSpinBox", + width = WeakAuras.normalWidth - indentWidth, + name = L["Texture X Offset"], + order = 7.06, + min = -1, + max = 1, + bigStep = 0.1, + hidden = hiddenIconExtra, + }, + texYOffset = { + type = "range", + control = "WeakAurasSpinBox", + width = WeakAuras.normalWidth, + name = L["Texture Y Offset"], + order = 7.07, + min = -1, + max = 1, + bigStep = 0.1, + hidden = hiddenIconExtra, + }, + iconExtra_space3 = { + type = "description", + name = "", + width = indentWidth, + order = 7.08, + hidden = hiddenIconExtra, + }, iconInset = { type = "range", control = "WeakAurasSpinBox", width = WeakAuras.normalWidth - indentWidth, name = L["Icon Inset"], - order = 7.06, + order = 7.09, min = 0, max = 1, bigStep = 0.01, @@ -171,7 +206,7 @@ local function createOptions(id, data) type = "toggle", width = WeakAuras.normalWidth, name = L["Keep Aspect Ratio"], - order = 7.07, + order = 7.10, hidden = hiddenIconExtra, }, iconExtraAnchor = { @@ -222,6 +257,21 @@ local function createOptions(id, data) order = 100, name = "", }, + ccWarning = { + type = "description", + width = WeakAuras.doubleWidth, + name = function() + if OmniCC then + return L["The addon OmniCC is enabled. It might add cooldown numbers to the swipe. You can configure these in the OmniCC settings"] + elseif ElvUI then + return L["The addon ElvUI is enabled. It might add cooldown numbers to the swipe. You can configure these in the ElvUI settings"] + else + return L["Cooldown Numbers might be added by WoW. You can configure these in the game settings."] + end + end, + order = 11.7, + hidden = function() return data.cooldownTextDisabled end + }, }; return { diff --git a/WeakAurasOptions/RegionOptions/Model.lua b/WeakAurasOptions/RegionOptions/Model.lua index d4ac7dd..fd718ed 100644 --- a/WeakAurasOptions/RegionOptions/Model.lua +++ b/WeakAurasOptions/RegionOptions/Model.lua @@ -297,4 +297,5 @@ local templates = { }, } -WeakAuras.RegisterRegionOptions("model", createOptions, createIcon, L["Model"], createThumbnail, modifyThumbnail, L["Shows a 3D model from the game files"], templates); +WeakAuras.RegisterRegionOptions("model", createOptions, createIcon, L["Model"], createThumbnail, modifyThumbnail, + L["Shows a 3D model from the game files"], templates)