From f208d8e2dcc9f3b7291fa7a1cb9c2b0639767a3f Mon Sep 17 00:00:00 2001 From: Weston Odom Date: Mon, 9 Oct 2023 17:12:16 -0400 Subject: [PATCH] added working CURVE grow type --- WeakAuras/RegionTypes/DynamicGroup.lua | 40 +++++++++++++++++++ WeakAuras/Types.lua | 1 + .../RegionOptions/DynamicGroup.lua | 17 ++++---- 3 files changed, 51 insertions(+), 7 deletions(-) diff --git a/WeakAuras/RegionTypes/DynamicGroup.lua b/WeakAuras/RegionTypes/DynamicGroup.lua index 552e02a0ae..94a8ef4d38 100644 --- a/WeakAuras/RegionTypes/DynamicGroup.lua +++ b/WeakAuras/RegionTypes/DynamicGroup.lua @@ -815,6 +815,46 @@ local growers = { end end, anchorOn end, + CURVE = function(data) + local oX, oY = 0, 0 + local radius = data.radius or 0 + local limit = data.useLimit and data.limit or math.huge + local sAngle = (data.rotation or 0) * math.pi / 180 + local arc = (data.fullCircle and 360 or data.arcLength or 0) * math.pi / 180 + local anchorPerUnitFunc, anchorOn + if data.useAnchorPerUnit then + anchorPerUnitFunc, anchorOn = createAnchorPerUnitFunc(data) + end + return function(newPositions, activeRegions) + local frames = {} + if anchorPerUnitFunc then + anchorPerUnitFunc(frames, activeRegions) + else + frames[""] = activeRegions + end + for frame, regionDatas in pairs(frames) do + local maxVisible = min(limit, #data.controlledChildren) + local r = radius + local theta = sAngle + local dAngle + if maxVisible == 1 then + dAngle = 0 + elseif not data.fullCircle then + dAngle = arc / (maxVisible - 1) + else + dAngle = arc / maxVisible + end + newPositions[frame] = {} + for i, regionData in ipairs(regionDatas) do + if i <= maxVisible then + local x, y = polarToRect(r, theta) + newPositions[frame][regionData] = { x, y, true } + theta = theta + dAngle + end + end + end + end, anchorOn + end, GRID = function(data) local gridType = data.gridType local gridWidth = data.gridWidth diff --git a/WeakAuras/Types.lua b/WeakAuras/Types.lua index d08c5a3dfc..a78a1d819e 100644 --- a/WeakAuras/Types.lua +++ b/WeakAuras/Types.lua @@ -2143,6 +2143,7 @@ Private.grow_types = { ["VERTICAL"] = L["Centered Vertical"], ["CIRCLE"] = L["Counter Clockwise"], ["COUNTERCIRCLE"] = L["Clockwise"], + ["CURVE"] = L["Curve"], ["GRID"] = L["Grid"], ["CUSTOM"] = L["Custom"], } diff --git a/WeakAurasOptions/RegionOptions/DynamicGroup.lua b/WeakAurasOptions/RegionOptions/DynamicGroup.lua index 322918124f..292d61857e 100644 --- a/WeakAurasOptions/RegionOptions/DynamicGroup.lua +++ b/WeakAurasOptions/RegionOptions/DynamicGroup.lua @@ -61,6 +61,7 @@ local selfPoints = { end, CIRCLE = "CENTER", COUNTERCIRCLE = "CENTER", + CURVE = "CENTER", } local gridSelfPoints = { @@ -214,8 +215,8 @@ local function createOptions(id, data) WeakAuras.ClearAndUpdateOptions(data.id) OptionsPrivate.ResetMoverSizer() end, - hidden = function() return (data.grow == "CUSTOM" or data.grow == "LEFT" or data.grow == "RIGHT" or data.grow == "HORIZONTAL" or data.grow == "CIRCLE" or data.grow == "COUNTERCIRCLE" or data.grow == "GRID") end, - disabled = function() return data.grow == "CIRCLE" or data.grow == "COUNTERCIRCLE" end + hidden = function() return (data.grow == "CUSTOM" or data.grow == "LEFT" or data.grow == "RIGHT" or data.grow == "HORIZONTAL" or data.grow == "CIRCLE" or data.grow == "COUNTERCIRCLE" or data.grow == "CURVE" or data.grow == "GRID") end, + disabled = function() return data.grow == "CIRCLE" or data.grow == "COUNTERCIRCLE" or data.grow == "CURVE" end }, rotated_align = { type = "select", @@ -223,7 +224,7 @@ local function createOptions(id, data) name = L["Align"], order = 3, values = OptionsPrivate.Private.rotated_align_types, - hidden = function() return (data.grow == "CUSTOM" or data.grow == "UP" or data.grow == "DOWN" or data.grow == "VERTICAL" or data.grow == "CIRCLE" or data.grow == "COUNTERCIRCLE" or data.grow == "GRID") end, + hidden = function() return (data.grow == "CUSTOM" or data.grow == "UP" or data.grow == "DOWN" or data.grow == "VERTICAL" or data.grow == "CIRCLE" or data.grow == "COUNTERCIRCLE" or data.grow == "CURVE" or data.grow == "GRID") end, get = function() return data.align; end, set = function(info, v) data.align = v @@ -269,14 +270,14 @@ local function createOptions(id, data) min = 0, max = 360, bigStep = 3, - hidden = function() return data.grow ~= "CIRCLE" and data.grow ~= "COUNTERCIRCLE" end + hidden = function() return data.grow ~= "CIRCLE" and data.grow ~= "COUNTERCIRCLE" and data.grow ~= "CURVE" end }, fullCircle = { type = "toggle", width = WeakAuras.normalWidth, name = L["Full Circle"], order = 7, - hidden = function() return data.grow ~= "CIRCLE" and data.grow ~= "COUNTERCIRCLE" end + hidden = function() return data.grow ~= "CIRCLE" and data.grow ~= "COUNTERCIRCLE" and data.grow ~= "CURVE" end }, arcLength = { type = "range", @@ -288,7 +289,7 @@ local function createOptions(id, data) max = 360, bigStep = 3, disabled = function() return data.fullCircle end, - hidden = function() return data.grow ~= "CIRCLE" and data.grow ~= "COUNTERCIRCLE" end + hidden = function() return data.grow ~= "CIRCLE" and data.grow ~= "COUNTERCIRCLE" and data.grow ~= "CURVE" end }, radius = { type = "range", @@ -299,7 +300,7 @@ local function createOptions(id, data) softMin = 0, softMax = 500, bigStep = 1, - hidden = function() return data.grow == "CUSTOM" or not((data.grow == "CIRCLE" or data.grow == "COUNTERCIRCLE") and data.constantFactor == "RADIUS") end + hidden = function() return data.grow == "CUSTOM" or not((data.grow == "CIRCLE" or data.grow == "COUNTERCIRCLE" or data.grow == "CURVE") and data.constantFactor == "RADIUS") end }, -- grid grow options gridType = { @@ -369,6 +370,7 @@ local function createOptions(id, data) hidden = function() return data.grow == "CUSTOM" or data.grow == "GRID" + or data.grow == "CURVE" or ((data.grow == "CIRCLE" or data.grow == "COUNTERCIRCLE") and data.constantFactor == "RADIUS") end }, @@ -386,6 +388,7 @@ local function createOptions(id, data) return data.grow == "CUSTOM" or data.grow == "CIRCLE" or data.grow == "COUNTERCIRCLE" + or data.grow == "CURVE" or data.grow == "GRID" end },