from retail

This commit is contained in:
NoM0Re
2025-01-10 16:16:47 +01:00
parent b89c221c34
commit a747346a9d
15 changed files with 240 additions and 42 deletions
+2 -2
View File
@@ -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;
+91 -14
View File
@@ -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
+12 -4
View File
@@ -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);