from retail

This commit is contained in:
NoM0Re
2025-01-09 20:23:53 +01:00
parent aee89075c9
commit 9e2bffcd20
4 changed files with 150 additions and 8 deletions
+83 -4
View File
@@ -700,9 +700,9 @@ local growers = {
local gridWidth = data.gridWidth
local rowSpace = data.rowSpace
local colSpace = data.columnSpace
local rowFirst = (gridType:find("^[RL]")) ~= nil
local rowFirst = (gridType:find("^[RLH]")) ~= nil
local limit = data.useLimit and data.limit or math.huge
local rowMul, colMul
local rowMul, colMul, primary_horizontal, secondary_horizontal, primary_vertical, secondary_vertical
if gridType:find("D") then
rowMul = -1
else
@@ -713,6 +713,16 @@ local growers = {
else
colMul = 1
end
if gridType:sub(1, 1) == "H" then
primary_horizontal = true
elseif gridType:sub(2, 2) == "H" then
secondary_horizontal = true
end
if gridType:sub(1, 1) == "V" then
primary_vertical = true
elseif gridType:sub(2, 2) == "V" then
secondary_vertical = true
end
local primary = {
-- x direction
dim = "width",
@@ -746,19 +756,81 @@ local growers = {
secondary.current = 0
secondary.max = 0
newPositions[frame] = {}
local minX, maxX, minY, maxY, totalMinX, totalMaxX, totalMinY, totalMaxY
local start
for i, regionData in ipairs(regionDatas) do
if i <= numVisible then
newPositions[frame][regionData] = { [primary.coord] = primary.current, [secondary.coord] = secondary.current, [3] = true }
newPositions[frame][regionData] = {
[primary.coord] = primary.current,
[secondary.coord] = secondary.current,
[3] = true
}
local x, y = newPositions[frame][regionData][1], newPositions[frame][regionData][2]
if minX == nil then
minX, maxX, minY, maxY = x, x, y, y
start = i
else
minX, maxX = math.min(minX, x), math.max(maxX, x)
minY, maxY = math.min(minY, y), math.max(maxY, y)
end
if totalMinX == nil then
totalMinX, totalMaxX, totalMinY, totalMaxY = x, x, y, y
else
totalMinX, totalMaxX = math.min(totalMinX, x), math.max(totalMaxX, x)
totalMinY, totalMaxY = math.min(totalMinY, y), math.max(totalMaxY, y)
end
secondary.max = max(secondary.max, getDimension(regionData, secondary.dim))
if i % gridWidth == 0 then
if primary_horizontal then
local offsetX = (maxX - minX) / 2
for j = start, i do
newPositions[frame][regionDatas[j]][1] = newPositions[frame][regionDatas[j]][1] - offsetX
end
end
if primary_vertical then
local offsetY = (maxY - minY) / 2
for j = start, i do
newPositions[frame][regionDatas[j]][2] = newPositions[frame][regionDatas[j]][2] - offsetY
end
end
primary.current = 0
secondary.current = secondary.current + (secondary.space + secondary.max) * secondary.mul
secondary.max = 0
minX, maxX = nil, nil
minY, maxY = nil, nil
else
primary.current = primary.current + (primary.space + getDimension(regionData, primary.dim)) * primary.mul
end
end
end
if (primary_horizontal or primary_vertical) and minX then
local offsetX = (maxX - minX) / 2
local offsetY = (maxY - minY) / 2
for j = start, #regionDatas do
if j <= numVisible then
if primary_horizontal then
newPositions[frame][regionDatas[j]][1] = newPositions[frame][regionDatas[j]][1] - offsetX
end
if primary_vertical then
newPositions[frame][regionDatas[j]][2] = newPositions[frame][regionDatas[j]][2] - offsetY
end
end
end
end
if (secondary_horizontal or secondary_vertical) and totalMinX then
local offsetX = (totalMaxX - totalMinX) / 2
local offsetY = (totalMaxY - totalMinY) / 2
for j = 1, #regionDatas do
if j <= numVisible then
if secondary_horizontal then
newPositions[frame][regionDatas[j]][1] = newPositions[frame][regionDatas[j]][1] - offsetX
end
if secondary_vertical then
newPositions[frame][regionDatas[j]][2] = newPositions[frame][regionDatas[j]][2] - offsetY
end
end
end
end
end
end
end,
@@ -795,7 +867,7 @@ local function modify(parent, region, data)
region:SetScale(data.scale and data.scale > 0 and data.scale <= 10 and data.scale or 1)
WeakAuras.regionPrototype.modify(parent, region, data)
if data.border and (data.grow ~= "CUSTOM" and not data.useAnchorPerUnit) then
if data.border and not data.useAnchorPerUnit then
local background = region.background
background:SetBackdrop({
edgeFile = data.borderEdge ~= "None" and SharedMedia:Fetch("border", data.borderEdge) or "",
@@ -1262,6 +1334,13 @@ local function modify(parent, region, data)
self:SetHeight(height)
self.currentWidth = width
self.currentHeight = height
local regionLeft = region:GetLeft()
local regionBottom = region:GetBottom()
self.background:SetPoint("BOTTOMLEFT", region, "BOTTOMLEFT", minX + -1 * data.borderOffset - regionLeft,
minY + -1 * data.borderOffset - regionBottom)
self.background:SetPoint("TOPRIGHT", region, "BOTTOMLEFT", maxX + data.borderOffset - regionLeft,
maxY + data.borderOffset - regionBottom)
else
self:Hide()
end
+10
View File
@@ -1821,6 +1821,16 @@ Private.grid_types = {
DR = L["Down, then Right"],
LD = L["Left, then Down"],
DL = L["Down, then Left"],
HD = L["Centered Horizontal, then Down"],
HU = L["Centered Horizontal, then Up"],
VR = L["Centered Vertical, then Right"],
VL = L["Centered Vertical, then Left"],
DH = L["Down, then Centered Horizontal"],
UH = L["Up, then Centered Horizontal"],
LV = L["Left, then Centered Vertical"],
RV = L["Right, then Centered Vertical"],
HV = L["Centered Horizontal, then Centered Vertical"],
VH = L["Centered Vertical, then Centered Horizontal"],
}
Private.text_rotate_types = {
+45 -2
View File
@@ -1726,6 +1726,10 @@ function WeakAuras.Delete(data)
if Private.regions[id] then
Private.regions[id].region:Collapse()
Private.CancelAnimation(Private.regions[id].region, true, true, true, true, true, true)
-- Groups have a empty Collapse method so, we need to hide them here
Private.regions[id].region:Hide();
Private.regions[id].region = nil
Private.regions[id] = nil
end
@@ -2194,7 +2198,23 @@ function Private.AddMany(tbl, takeSnapshots)
end
idtable[data.id] = data;
if data.anchorFrameType == "SELECTFRAME" and data.anchorFrameFrame and data.anchorFrameFrame:sub(1, 10) == "WeakAuras:" then
anchorTargets[data.anchorFrameFrame:sub(11)] = true
anchorTargets[data.anchorFrameFrame:sub(11)] = data.id
end
end
-- Now fix up anchors, see #3971, where aura p was anchored to aura c and where c was a child of p, thus c was anchored to p
-- The game used to detect such anchoring circles. We can't detect all of them, but at least detect the one from the ticket.
for target, source in pairs(anchorTargets) do
-- We walk up the parent's of target, to check for source
local parent = target
if idtable[target] then
while(parent) do
if parent == source then
WeakAuras.prettyPrint(L["Warning: Anchoring to your own child '%s' in aura '%s' is imposssible."]:format(target, source))
idtable[source].anchorFrameType = "SCREEN"
end
parent = idtable[parent].parent
end
end
end
@@ -2653,7 +2673,7 @@ local function pAdd(data, simpleChange)
else
Private.DebugLog.SetEnabled(data.uid, data.information.debugLog)
if (data.controlledChildren) then
if Private.IsGroupType(data) then
Private.ClearAuraEnvironment(id);
for parent in Private.TraverseParents(data) do
Private.ClearAuraEnvironment(parent.id);
@@ -2666,6 +2686,8 @@ local function pAdd(data, simpleChange)
loadEvents["GROUP"] = loadEvents["GROUP"] or {}
loadEvents["GROUP"][id] = true
else -- Non group aura
-- Make sure that we don't have a controlledChildren member.
data.controlledChildren = nil
local visible
if (WeakAuras.IsOptionsOpen()) then
visible = Private.FakeStatesFor(id, false)
@@ -4041,6 +4063,16 @@ function Private.AddToWatchedTriggerDelay(id, triggernum)
delayed_watched_trigger[id] = delayed_watched_trigger[id] or {}
tinsert(delayed_watched_trigger[id], triggernum)
end
Private.callbacks:RegisterCallback("Delete", function(_, uid, id)
delayed_watched_trigger[id] = nil
end)
Private.callbacks:RegisterCallback("Rename", function(_, uid, oldId, newId)
delayed_watched_trigger[newId] = delayed_watched_trigger[oldId]
delayed_watched_trigger[oldId] = nil
end)
function Private.SendDelayedWatchedTriggers()
for id in pairs(delayed_watched_trigger) do
local watched = delayed_watched_trigger[id]
@@ -4984,6 +5016,17 @@ local function GetAnchorFrame(data, region, parent)
if (frame_name == id) then
return parent;
end
local targetData = WeakAuras.GetData(frame_name)
if targetData then
for parentData in Private.TraverseParents(targetData) do
if parentData.id == data.id then
WeakAuras.prettyPrint(L["Warning: Anchoring to your own child '%s' in aura '%s' is imposssible."]:format(frame_name, data.id))
return parent
end
end
end
if(Private.regions[frame_name]) then
return Private.regions[frame_name].region;
end
@@ -72,6 +72,16 @@ local gridSelfPoints = {
DR = "TOPLEFT",
LD = "TOPRIGHT",
DL = "TOPRIGHT",
HD = "TOP",
HU = "BOTTOM",
VR = "LEFT",
VL = "RIGHT",
DH = "TOP",
UH = "BOTTOM",
LV = "RIGHT",
RV = "LEFT",
HV = "CENTER",
VH = "CENTER",
}
local function createOptions(id, data)
@@ -267,7 +277,7 @@ local function createOptions(id, data)
width = WeakAuras.normalWidth,
name = function()
if not data.gridType then return "" end
if data.gridType:find("^[RL]") then
if data.gridType:find("^[RLH]") then
return L["Row Width"]
else
return L["Column Height"]
@@ -448,7 +458,7 @@ local function createOptions(id, data)
OptionsPrivate.commonOptions.AddCodeOption(options, data, L["Custom Anchor"], "custom_anchor_per_unit", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#group-by-frame",
1.7, function() return not(data.grow ~= "CUSTOM" and data.useAnchorPerUnit and data.anchorPerUnit == "CUSTOM") end, {"customAnchorPerUnit"}, false, { setOnParent = true })
local borderHideFunc = function() return data.useAnchorPerUnit or data.grow == "CUSTOM" end
local borderHideFunc = function() return data.useAnchorPerUnit end
local disableSelfPoint = function() return data.grow ~= "CUSTOM" and data.grow ~= "GRID" and not data.useAnchorPerUnit end
for k, v in pairs(OptionsPrivate.commonOptions.BorderOptions(id, data, nil, borderHideFunc, 70)) do