from retail

This commit is contained in:
NoM0Re
2025-01-16 15:49:20 +01:00
parent c090302487
commit bbb47ec07d
2 changed files with 77 additions and 21 deletions
+58 -21
View File
@@ -392,7 +392,7 @@ local anchorers = {
tinsert(frames[Private.personalRessourceDisplayFrame], regionData) tinsert(frames[Private.personalRessourceDisplayFrame], regionData)
end end
end end
end end, {unit = true }
end, end,
["UNITFRAME"] = function(data) ["UNITFRAME"] = function(data)
return function(frames, activeRegions) return function(frames, activeRegions)
@@ -406,11 +406,21 @@ local anchorers = {
end end
end end
end end
end end, {unit = true }
end, end,
["CUSTOM"] = function(data) ["CUSTOM"] = function(data)
local anchorStr = data.customAnchorPerUnit or "" local anchorStr = data.customAnchorPerUnit or ""
local anchorFunc = WeakAuras.LoadFunction("return " .. anchorStr) or noop local anchorFunc = WeakAuras.LoadFunction("return " .. anchorStr) or noop
local anchorOn = nil
local events = WeakAuras.split(data.anchorOn or "")
if #events > 0 then
anchorOn = {}
for _, event in ipairs(events) do
anchorOn[event] = true
end
end
return function(frames, activeRegions) return function(frames, activeRegions)
Private.ActivateAuraEnvironment(data.id) Private.ActivateAuraEnvironment(data.id)
local ok, ret = pcall(anchorFunc, frames, activeRegions) local ok, ret = pcall(anchorFunc, frames, activeRegions)
@@ -418,7 +428,7 @@ local anchorers = {
Private.GetErrorHandlerUid(data.uid, L["Custom Anchor"]) Private.GetErrorHandlerUid(data.uid, L["Custom Anchor"])
end end
Private.ActivateAuraEnvironment() Private.ActivateAuraEnvironment()
end end, anchorOn
end end
} }
@@ -508,7 +518,10 @@ local growers = {
local limit = data.useLimit and data.limit or math.huge local limit = data.useLimit and data.limit or math.huge
local startX, startY = 0, 0 local startX, startY = 0, 0
local coeff = staggerCoefficient(data.align, data.stagger) local coeff = staggerCoefficient(data.align, data.stagger)
local anchorPerUnitFunc = data.useAnchorPerUnit and createAnchorPerUnitFunc(data) local anchorPerUnitFunc, anchorOn
if data.useAnchorPerUnit then
anchorPerUnitFunc, anchorOn = createAnchorPerUnitFunc(data)
end
return function(newPositions, activeRegions) return function(newPositions, activeRegions)
local frames = {} local frames = {}
if anchorPerUnitFunc then if anchorPerUnitFunc then
@@ -528,7 +541,7 @@ local growers = {
end end
end end
end end
end end, anchorOn
end, end,
RIGHT = function(data) RIGHT = function(data)
local stagger = data.stagger or 0 local stagger = data.stagger or 0
@@ -536,7 +549,10 @@ local growers = {
local limit = data.useLimit and data.limit or math.huge local limit = data.useLimit and data.limit or math.huge
local startX, startY = 0, 0 local startX, startY = 0, 0
local coeff = 1 - staggerCoefficient(data.align, stagger) local coeff = 1 - staggerCoefficient(data.align, stagger)
local anchorPerUnitFunc = data.useAnchorPerUnit and createAnchorPerUnitFunc(data) local anchorPerUnitFunc, anchorOn
if data.useAnchorPerUnit then
anchorPerUnitFunc, anchorOn = createAnchorPerUnitFunc(data)
end
return function(newPositions, activeRegions) return function(newPositions, activeRegions)
local frames = {} local frames = {}
if anchorPerUnitFunc then if anchorPerUnitFunc then
@@ -556,7 +572,7 @@ local growers = {
end end
end end
end end
end end, anchorOn
end, end,
UP = function(data) UP = function(data)
local stagger = data.stagger or 0 local stagger = data.stagger or 0
@@ -564,7 +580,10 @@ local growers = {
local limit = data.useLimit and data.limit or math.huge local limit = data.useLimit and data.limit or math.huge
local startX, startY = 0, 0 local startX, startY = 0, 0
local coeff = 1 - staggerCoefficient(data.align, stagger) local coeff = 1 - staggerCoefficient(data.align, stagger)
local anchorPerUnitFunc = data.useAnchorPerUnit and createAnchorPerUnitFunc(data) local anchorPerUnitFunc, anchorOn
if data.useAnchorPerUnit then
anchorPerUnitFunc, anchorOn = createAnchorPerUnitFunc(data)
end
return function(newPositions, activeRegions) return function(newPositions, activeRegions)
local frames = {} local frames = {}
if anchorPerUnitFunc then if anchorPerUnitFunc then
@@ -584,7 +603,7 @@ local growers = {
end end
end end
end end
end end, anchorOn
end, end,
DOWN = function(data) DOWN = function(data)
local stagger = data.stagger or 0 local stagger = data.stagger or 0
@@ -592,7 +611,10 @@ local growers = {
local limit = data.useLimit and data.limit or math.huge local limit = data.useLimit and data.limit or math.huge
local startX, startY = 0, 0 local startX, startY = 0, 0
local coeff = staggerCoefficient(data.align, stagger) local coeff = staggerCoefficient(data.align, stagger)
local anchorPerUnitFunc = data.useAnchorPerUnit and createAnchorPerUnitFunc(data) local anchorPerUnitFunc, anchorOn
if data.useAnchorPerUnit then
anchorPerUnitFunc, anchorOn = createAnchorPerUnitFunc(data)
end
return function(newPositions, activeRegions) return function(newPositions, activeRegions)
local frames = {} local frames = {}
if anchorPerUnitFunc then if anchorPerUnitFunc then
@@ -612,14 +634,17 @@ local growers = {
end end
end end
end end
end end, anchorOn
end, end,
HORIZONTAL = function(data) HORIZONTAL = function(data)
local stagger = data.stagger or 0 local stagger = data.stagger or 0
local space = data.space or 0 local space = data.space or 0
local limit = data.useLimit and data.limit or math.huge local limit = data.useLimit and data.limit or math.huge
local midX, midY = 0, 0 local midX, midY = 0, 0
local anchorPerUnitFunc = data.useAnchorPerUnit and createAnchorPerUnitFunc(data) local anchorPerUnitFunc, anchorOn
if data.useAnchorPerUnit then
anchorPerUnitFunc, anchorOn = createAnchorPerUnitFunc(data)
end
local FirstIndex = centeredIndexerStart[data.centerType] local FirstIndex = centeredIndexerStart[data.centerType]
local NextIndex = centeredIndexerNext[data.centerType] local NextIndex = centeredIndexerNext[data.centerType]
return function(newPositions, activeRegions) return function(newPositions, activeRegions)
@@ -648,14 +673,17 @@ local growers = {
i = NextIndex(i, numVisible) i = NextIndex(i, numVisible)
end end
end end
end end, anchorOn
end, end,
VERTICAL = function(data) VERTICAL = function(data)
local stagger = -(data.stagger or 0) local stagger = -(data.stagger or 0)
local space = data.space or 0 local space = data.space or 0
local limit = data.useLimit and data.limit or math.huge local limit = data.useLimit and data.limit or math.huge
local midX, midY = 0, 0 local midX, midY = 0, 0
local anchorPerUnitFunc = data.useAnchorPerUnit and createAnchorPerUnitFunc(data) local anchorPerUnitFunc, anchorOn
if data.useAnchorPerUnit then
anchorPerUnitFunc, anchorOn = createAnchorPerUnitFunc(data)
end
local FirstIndex = centeredIndexerStart[data.centerType] local FirstIndex = centeredIndexerStart[data.centerType]
local NextIndex = centeredIndexerNext[data.centerType] local NextIndex = centeredIndexerNext[data.centerType]
return function(newPositions, activeRegions) return function(newPositions, activeRegions)
@@ -684,7 +712,7 @@ local growers = {
i = NextIndex(i, numVisible) i = NextIndex(i, numVisible)
end end
end end
end end, anchorOn
end, end,
CIRCLE = function(data) CIRCLE = function(data)
local oX, oY = 0, 0 local oX, oY = 0, 0
@@ -694,7 +722,10 @@ local growers = {
local limit = data.useLimit and data.limit or math.huge local limit = data.useLimit and data.limit or math.huge
local sAngle = (data.rotation or 0) * math.pi / 180 local sAngle = (data.rotation or 0) * math.pi / 180
local arc = (data.fullCircle and 360 or data.arcLength or 0) * math.pi / 180 local arc = (data.fullCircle and 360 or data.arcLength or 0) * math.pi / 180
local anchorPerUnitFunc = data.useAnchorPerUnit and createAnchorPerUnitFunc(data) local anchorPerUnitFunc, anchorOn
if data.useAnchorPerUnit then
anchorPerUnitFunc, anchorOn = createAnchorPerUnitFunc(data)
end
return function(newPositions, activeRegions) return function(newPositions, activeRegions)
local frames = {} local frames = {}
if anchorPerUnitFunc then if anchorPerUnitFunc then
@@ -732,7 +763,7 @@ local growers = {
end end
end end
end end
end end, anchorOn
end, end,
COUNTERCIRCLE = function(data) COUNTERCIRCLE = function(data)
local oX, oY = 0, 0 local oX, oY = 0, 0
@@ -742,7 +773,10 @@ local growers = {
local limit = data.useLimit and data.limit or math.huge local limit = data.useLimit and data.limit or math.huge
local sAngle = (data.rotation or 0) * math.pi / 180 local sAngle = (data.rotation or 0) * math.pi / 180
local arc = (data.fullCircle and 360 or data.arcLength or 0) * math.pi / 180 local arc = (data.fullCircle and 360 or data.arcLength or 0) * math.pi / 180
local anchorPerUnitFunc = data.useAnchorPerUnit and createAnchorPerUnitFunc(data) local anchorPerUnitFunc, anchorOn
if data.useAnchorPerUnit then
anchorPerUnitFunc, anchorOn = createAnchorPerUnitFunc(data)
end
return function(newPositions, activeRegions) return function(newPositions, activeRegions)
local frames = {} local frames = {}
if anchorPerUnitFunc then if anchorPerUnitFunc then
@@ -780,7 +814,7 @@ local growers = {
end end
end end
end end
end end, anchorOn
end, end,
GRID = function(data) GRID = function(data)
local gridType = data.gridType local gridType = data.gridType
@@ -829,7 +863,10 @@ local growers = {
if not rowFirst then if not rowFirst then
primary, secondary = secondary, primary primary, secondary = secondary, primary
end end
local anchorPerUnitFunc = data.useAnchorPerUnit and createAnchorPerUnitFunc(data) local anchorPerUnitFunc, anchorOn
if data.useAnchorPerUnit then
anchorPerUnitFunc, anchorOn = createAnchorPerUnitFunc(data)
end
return function(newPositions, activeRegions) return function(newPositions, activeRegions)
local frames = {} local frames = {}
if anchorPerUnitFunc then if anchorPerUnitFunc then
@@ -919,7 +956,7 @@ local growers = {
end end
end end
end end
end end, anchorOn
end, end,
CUSTOM = function(data) CUSTOM = function(data)
local growStr = data.customGrow or "" local growStr = data.customGrow or ""
@@ -182,6 +182,25 @@ local function createOptions(id, data)
hidden = function() return data.grow == "CUSTOM" end, hidden = function() return data.grow == "CUSTOM" end,
disabled = function() return not data.useAnchorPerUnit end disabled = function() return not data.useAnchorPerUnit end
}, },
anchorOn = {
type = "input",
width = WeakAuras.doubleWidth,
name = L["Run on..."],
desc = L["You can add a comma-separated list of state values here that (when changed) WeakAuras should also run the Anchor Code on.\n\nWeakAuras will always run custom anchor code if you include 'changed' in this list, or when a region is added, removed, or re-ordered."],
order = 1.61,
get = function()
return data.anchorOn or ""
end,
hidden = function()
return not(data.grow ~= "CUSTOM" and data.useAnchorPerUnit and data.anchorPerUnit == "CUSTOM")
end,
set = function(info, v)
data.anchorOn = v
WeakAuras.Add(data)
WeakAuras.ClearAndUpdateOptions(data.id)
OptionsPrivate.ResetMoverSizer()
end
},
-- custom grow option added below -- custom grow option added below
align = { align = {
type = "select", type = "select",