from retail

This commit is contained in:
NoM0Re
2025-01-26 21:24:18 +01:00
parent 1793d7ac19
commit f9bf9c3c16
25 changed files with 1467 additions and 500 deletions
+107
View File
@@ -1463,6 +1463,112 @@ local function PositionOptions(id, data, _, hideWidthHeight, disableSelfPoint, g
return positionOptions;
end
local function PositionOptionsForSubElement(data, options, startOrder, areaAnchors, pointAnchors)
options.anchor_mode = {
name = L["Anchor Mode"],
type = "select",
width = WeakAuras.normalWidth,
order = startOrder,
values = OptionsPrivate.Private.anchor_mode,
}
options.anchor_area = {
name = L["Area"],
type = "select",
width = WeakAuras.normalWidth,
control = "WeakAurasTwoColumnDropdown",
order = startOrder + 0.1,
values = areaAnchors,
hidden = function()
return data.anchor_mode == "point"
end
}
options.anchor_space = {
name = "",
type = "description",
order = startOrder + 0.2,
hidden = function()
return data.anchor_mode == "area"
end
}
options.self_point = {
name = L["Anchor"],
type = "select",
width = WeakAuras.normalWidth,
control = "WeakAurasTwoColumnDropdown",
order = startOrder + 0.3,
values = OptionsPrivate.Private.point_types,
hidden = function()
return data.anchor_mode == "area"
end
}
options.anchor_point = {
name = L["To Region's"],
type = "select",
width = WeakAuras.normalWidth,
control = "WeakAurasTwoColumnDropdown",
order = startOrder + 0.4,
values = pointAnchors,
hidden = function()
return data.anchor_mode == "area"
end
}
options.width = {
name = L["Width"],
type = "range",
control = "WeakAurasSpinBox",
width = WeakAuras.normalWidth,
min = 0,
softMax = 200,
step = 1,
order = startOrder + 0.5,
hidden = function()
return data.anchor_mode == "area"
end
}
options.height = {
name = L["Height"],
type = "range",
control = "WeakAurasSpinBox",
width = WeakAuras.normalWidth,
min = 0,
softMax = 200,
step = 1,
order = startOrder + 0.6,
hidden = function()
return data.anchor_mode == "area"
end
}
options.xOffset = {
type = "range",
control = "WeakAurasSpinBox",
name = L["X Offset"],
order = startOrder + 0.7,
width = WeakAuras.normalWidth,
softMin = -200,
softMax = 200,
step = 1,
}
options.yOffset = {
type = "range",
control = "WeakAurasSpinBox",
name = L["Y Offset"],
order = startOrder + 0.8,
width = WeakAuras.normalWidth,
softMin = -200,
softMax = 200,
step = 1,
}
end
local function BorderOptions(id, data, showBackDropOptions, hiddenFunc, order)
local borderOptions = {
borderHeader = {
@@ -1794,6 +1900,7 @@ OptionsPrivate.commonOptions.CreateSetAll = CreateSetAll
OptionsPrivate.commonOptions.CreateExecuteAll = CreateExecuteAll
OptionsPrivate.commonOptions.PositionOptions = PositionOptions
OptionsPrivate.commonOptions.PositionOptionsForSubElement = PositionOptionsForSubElement
OptionsPrivate.commonOptions.ProgressOptions = ProgressOptions
OptionsPrivate.commonOptions.BorderOptions = BorderOptions
OptionsPrivate.commonOptions.AddCodeOption = AddCodeOption
+18 -2
View File
@@ -839,10 +839,26 @@ local anchorPoints = {
display = L["Spark"],
type = "point"
},
ALL = {
display = L["Whole Area"],
bar = {
display = L["Full Bar"],
type = "area"
},
icon = {
display = L["Icon"],
type = "area"
},
fg = {
display = L["Foreground"],
type = "area"
},
bg = {
display = L["Background"],
type = "area"
}
}
local function GetAnchors(data)
+4 -95
View File
@@ -6,101 +6,10 @@ local AddonName, OptionsPrivate = ...
local texture_types = WeakAuras.StopMotion.texture_types;
local texture_data = WeakAuras.StopMotion.texture_data;
local animation_types = WeakAuras.StopMotion.animation_types;
local setTile = WeakAuras.setTile
local function setTextureFunc(textureWidget, texturePath, textureName)
local data = texture_data[texturePath];
if not(data) then
local pattern = "%.x(%d+)y(%d+)f(%d+)%.[tb][gl][ap]"
local pattern2 = "%.x(%d+)y(%d+)f(%d+)w(%d+)h(%d+)W(%d+)H(%d+)%.[tb][gl][ap]"
local rows, columns, frames = texturePath:lower():match(pattern)
if rows then
data = {
count = tonumber(frames),
rows = tonumber(rows),
columns = tonumber(columns)
}
else
local rows, columns, frames, frameWidth, frameHeight, fileWidth, fileHeight = texturePath:match(pattern2)
if rows then
rows, columns, frames, frameWidth, frameHeight, fileWidth, fileHeight
= tonumber(rows), tonumber(columns), tonumber(frames), tonumber(frameWidth), tonumber(frameHeight), tonumber(fileWidth), tonumber(fileHeight)
local frameScaleW = 1
local frameScaleH = 1
if fileWidth > 0 and frameWidth > 0 then
frameScaleW = (frameWidth * columns) / fileWidth
end
if fileHeight > 0 and frameHeight > 0 then
frameScaleH = (frameHeight * rows) / fileHeight
end
data = {
count = frames,
rows = rows,
columns = columns,
frameScaleW = frameScaleW,
frameScaleH = frameScaleH
}
end
end
end
textureWidget.frameNr = 0;
if (data) then
if (data.rows and data.columns) then
-- Texture Atlas
textureWidget:SetTexture(texturePath, textureName);
setTile(textureWidget, data.count, data.rows, data.columns, data.frameScaleW or 1, data.frameScaleH or 1);
textureWidget:SetOnUpdate(function(self, elapsed)
self.elapsed = (self.elapsed or 0) + elapsed
if(self.elapsed > 0.1) then
self.elapsed = self.elapsed - 0.1;
textureWidget.frameNr = textureWidget.frameNr + 1;
if (textureWidget.frameNr == data.count) then
textureWidget.frameNr = 1;
end
setTile(textureWidget, textureWidget.frameNr, data.rows, data.columns, data.frameScaleW or 1, data.frameScaleH or 1);
end
end)
else
-- Numbered Textures
local texture = texturePath .. format("%03d", texture_data[texturePath].count)
textureWidget:SetTexture(texture, textureName)
textureWidget:SetTexCoord(0, 1, 0, 1);
textureWidget:SetOnUpdate(function(self, elapsed)
self.elapsed = (self.elapsed or 0) + elapsed
if(self.elapsed > 0.1) then
self.elapsed = self.elapsed - 0.1;
textureWidget.frameNr = textureWidget.frameNr + 1;
if (textureWidget.frameNr == data.count) then
textureWidget.frameNr = 1;
end
local texture = texturePath .. format("%03d", textureWidget.frameNr)
textureWidget:SetTexture(texture, textureName);
end
end);
end
else
local texture = texturePath .. format("%03d", 1)
textureWidget:SetTexture(texture, textureName);
end
end
local function textureNameHasData(textureName)
local pattern = "%.x(%d+)y(%d+)f(%d+)%.[tb][gl][ap]$"
local pattern2 = "%.x(%d+)y(%d+)f(%d+)w(%d+)h(%d+)W(%d+)H(%d+)%.[tb][gl][ap]$"
local ok = textureName:lower():match(pattern)
if ok then return true end
local ok2 = textureName:match(pattern2)
if ok2 then
return true
else
return false
end
end
local function createOptions(id, data)
local textureNameHasData = OptionsPrivate.Private.StopMotionBase.textureNameHasData
local setTextureFunc = OptionsPrivate.Private.StopMotionBase.setTextureFunc
local options = {
__title = L["Stop Motion Settings"],
__order = 1,
@@ -691,11 +600,11 @@ local function modifyThumbnail(parent, region, data, fullModify, size)
frameScaleH = (region.foreground.frameHeight * region.foreground.rows) / region.foreground.fileHeight
end
setTile(region.texture, frame, region.foreground.rows, region.foreground.columns, frameScaleW, frameScaleH);
WeakAuras.setTile(region.texture, frame, region.foreground.rows, region.foreground.columns, frameScaleW, frameScaleH);
region.SetValue = function(self, percent)
local frame = floor(percent * (region.endFrame - region.startFrame) + region.startFrame);
setTile(self.texture, frame, region.foreground.rows, region.foreground.columns, frameScaleW, frameScaleH);
WeakAuras.setTile(self.texture, frame, region.foreground.rows, region.foreground.columns, frameScaleW, frameScaleH);
end
else
region.texture:SetTexture(texture .. format("%03d", frame));
+6 -2
View File
@@ -4,6 +4,10 @@ local AddonName, OptionsPrivate = ...
local L = WeakAuras.L;
local function createOptions(parentData, data, index, subIndex)
local areaAnchors = {}
for child in OptionsPrivate.Private.TraverseLeafsOrAura(parentData) do
WeakAuras.Mixin(areaAnchors, OptionsPrivate.Private.GetAnchorsForData(child, "area"))
end
local options = {
__title = L["Border %s"]:format(subIndex),
__order = 1,
@@ -48,12 +52,12 @@ local function createOptions(parentData, data, index, subIndex)
softMax = 64,
bigStep = 1,
},
border_anchor = {
anchor_area = {
type = "select",
width = WeakAuras.normalWidth,
name = L["Border Anchor"],
order = 7,
values = OptionsPrivate.Private.aurabar_anchor_areas,
values = areaAnchors,
hidden = function() return parentData.regionType ~= "aurabar" end
}
}
+6 -2
View File
@@ -6,6 +6,10 @@ local L = WeakAuras.L;
local indentWidth = 0.15
local function createOptions(parentData, data, index, subIndex)
local areaAnchors = {}
for child in OptionsPrivate.Private.TraverseLeafsOrAura(parentData) do
WeakAuras.Mixin(areaAnchors, OptionsPrivate.Private.GetAnchorsForData(child, "area"))
end
local hiddenGlowExtra = function()
return OptionsPrivate.IsCollapsed("glow", "glow", "glowextra" .. index, true);
@@ -27,12 +31,12 @@ local function createOptions(parentData, data, index, subIndex)
order = 2,
values = OptionsPrivate.Private.glow_types,
},
glow_anchor = {
anchor_area = {
type = "select",
width = WeakAuras.normalWidth,
name = L["Glow Anchor"],
order = 3,
values = OptionsPrivate.Private.aurabar_anchor_areas,
values = areaAnchors,
hidden = function() return parentData.regionType ~= "aurabar" end
},
glowExtraDescription = {
@@ -0,0 +1,350 @@
if not WeakAuras.IsLibsOK() then return end
---@type string
local AddonName = ...
---@class OptionsPrivate
local OptionsPrivate = select(2, ...)
local L = WeakAuras.L;
local texture_types = WeakAuras.StopMotion.texture_types
local texture_data = WeakAuras.StopMotion.texture_data
local animation_types = WeakAuras.StopMotion.animation_types
local function createOptions(parentData, data, index, subIndex)
local pointAnchors = {}
local areaAnchors = {}
for child in OptionsPrivate.Private.TraverseLeafsOrAura(parentData) do
WeakAuras.Mixin(pointAnchors, OptionsPrivate.Private.GetAnchorsForData(child, "point"))
WeakAuras.Mixin(areaAnchors, OptionsPrivate.Private.GetAnchorsForData(child, "area"))
end
local textureNameHasData = OptionsPrivate.Private.StopMotionBase.textureNameHasData
local setTextureFunc = OptionsPrivate.Private.StopMotionBase.setTextureFunc
local options = {
__title = L["Stop Motion %s"]:format(subIndex),
__order = 1,
stopmotionVisible = {
type = "toggle",
width = WeakAuras.doubleWidth,
name = L["Show Stop Motion"],
order = 1,
},
stopmotionTexture = {
type = "input",
width = WeakAuras.doubleWidth - 0.15,
name = L["Texture"],
order = 2,
},
chooseTexture = {
type = "execute",
width = 0.15,
name = L["Choose"],
order = 3,
func = function()
local path = { "subRegions", index }
local paths = {}
for child in OptionsPrivate.Private.TraverseLeafsOrAura(parentData) do
paths[child.id] = path
end
OptionsPrivate.OpenTexturePicker(parentData, paths, {
texture = "stopmotionTexture",
color = "stopmotionColor",
blendMode = "stopmotionBlendMode"
}, texture_types, setTextureFunc)
end,
imageWidth = 24,
imageHeight = 24,
control = "WeakAurasIcon",
image = "Interface\\AddOns\\WeakAuras\\Media\\Textures\\browse",
},
stopmotionColor = {
type = "color",
width = WeakAuras.normalWidth,
name = L["Color"],
hasAlpha = true,
order = 4
},
stopmotionDesaturate = {
type = "toggle",
width = WeakAuras.normalWidth,
name = L["Desaturate"],
order = 5,
},
customRows = {
type = "input",
width = WeakAuras.doubleWidth / 3,
name = L["Rows"],
validate = WeakAuras.ValidateNumeric,
get = function()
return data.customRows and tostring(data.customRows) or "";
end,
set = function(info, v)
data.customRows = v and tonumber(v) or 0
WeakAuras.Add(data);
WeakAuras.UpdateThumbnail(data);
end,
order = 6,
hidden = function()
return texture_data[data.stopmotionTexture] or textureNameHasData(data.stopmotionTexture)
end
},
customColumns = {
type = "input",
width = WeakAuras.doubleWidth / 3,
name = L["Columns"],
validate = WeakAuras.ValidateNumeric,
get = function()
return data.customColumns and tostring(data.customColumns) or "";
end,
set = function(info, v)
data.customColumns = v and tonumber(v) or 0
WeakAuras.Add(data);
WeakAuras.UpdateThumbnail(data);
end,
order = 7,
hidden = function()
return texture_data[data.stopmotionTexture] or textureNameHasData(data.stopmotionTexture)
end
},
customFrames = {
type = "input",
width = WeakAuras.doubleWidth / 3,
name = L["Frame Count"],
validate = WeakAuras.ValidateNumeric,
get = function()
return data.customFrames and tostring(data.customFrames) or "";
end,
set = function(info, v)
data.customFrames = v and tonumber(v) or 0
WeakAuras.Add(data);
WeakAuras.UpdateThumbnail(data);
end,
order = 8,
hidden = function()
return texture_data[data.stopmotionTexture] or textureNameHasData(data.stopmotionTexture)
end
},
customFileWidth = {
type = "input",
width = WeakAuras.normalWidth / 2,
name = L["File Width"],
desc = L["Must be a power of 2"],
validate = function(info, val)
if val ~= nil and val ~= "" and (not tonumber(val) or tonumber(val) >= 2^31 or math.frexp(val) ~= 0.5) then
return false;
end
return true
end,
get = function()
return data.customFileWidth and tostring(data.customFileWidth) or "";
end,
set = function(info, v)
data.customFileWidth = v and tonumber(v) or 0
WeakAuras.Add(data);
WeakAuras.UpdateThumbnail(data);
end,
order = 9,
hidden = function()
return texture_data[data.stopmotionTexture] or textureNameHasData(data.stopmotionTexture)
end
},
customFileHeight = {
type = "input",
width = WeakAuras.normalWidth / 2,
name = L["File Height"],
desc = L["Must be a power of 2"],
validate = function(info, val)
if val ~= nil and val ~= "" and (not tonumber(val) or tonumber(val) >= 2^31 or math.frexp(val) ~= 0.5) then
return false;
end
return true
end,
get = function()
return data.customFileHeight and tostring(data.customFileHeight) or "";
end,
set = function(info, v)
data.customFileHeight = v and tonumber(v) or 0
WeakAuras.Add(data);
WeakAuras.UpdateThumbnail(data);
end,
order = 10,
hidden = function()
return texture_data[data.stopmotionTexture] or textureNameHasData(data.stopmotionTexture)
end
},
customFrameWidth = {
type = "input",
width = WeakAuras.normalWidth / 2,
name = L["Frame Width"],
validate = WeakAuras.ValidateNumeric,
desc = L["Can set to 0 if Columns * Width equal File Width"],
get = function()
return data.customFrameWidth and tostring(data.customFrameWidth) or "";
end,
set = function(info, v)
data.customFrameWidth = v and tonumber(v) or 0
WeakAuras.Add(data);
WeakAuras.UpdateThumbnail(data);
end,
order = 11,
hidden = function()
return texture_data[data.stopmotionTexture] or textureNameHasData(data.stopmotionTexture)
end
},
customFrameHeight = {
type = "input",
width = WeakAuras.normalWidth / 2,
name = L["Frame Height"],
validate = WeakAuras.ValidateNumeric,
desc = L["Can set to 0 if Rows * Height equal File Height"],
get = function()
return data.customFrameHeight and tostring(data.customFrameHeight) or "";
end,
set = function(info, v)
data.customFrameHeight = v and tonumber(v) or 0
WeakAuras.Add(data);
WeakAuras.UpdateThumbnail(data);
end,
order = 12,
hidden = function()
return texture_data[data.stopmotionTexture] or textureNameHasData(data.stopmotionTexture)
end
},
stopmotionBlendMode = {
type = "select",
width = WeakAuras.normalWidth,
name = L["Blend Mode"],
order = 13,
values = OptionsPrivate.Private.blend_types
},
animationType = {
type = "select",
width = WeakAuras.normalWidth,
name = L["Animation Mode"],
order = 14,
values = animation_types
},
progress_source = {
type = "select",
width = WeakAuras.normalWidth,
name = L["Progress Source"],
order = 15,
control = "WeakAurasTwoColumnDropdown",
values = OptionsPrivate.Private.GetProgressSourcesForUi(parentData, true),
get = function(info)
return OptionsPrivate.Private.GetProgressValueConstant(data.progressSources or {-2, ""})
end,
set = function(info, value)
if value then
data.progressSources = data.progressSources or {}
-- Copy only trigger + property
data.progressSources[1] = value[1]
data.progressSources[2] = value[2]
else
data.progressSources = nil
end
WeakAuras.Add(parentData)
end,
hidden = function()
return not(data.animationType == "progress")
end
},
progress_source_space = {
type = "description",
name = "",
order = 16,
width = WeakAuras.normalWidth,
hidden = function()
return not(data.animationType == "progress")
end
},
startPercent = {
type = "range",
control = "WeakAurasSpinBox",
width = WeakAuras.normalWidth,
name = L["Animation Start"],
min = 0,
max = 1,
--bigStep = 0.01,
order = 17,
isPercent = true
},
endPercent = {
type = "range",
control = "WeakAurasSpinBox",
width = WeakAuras.normalWidth,
name = L["Animation End"],
min = 0,
max = 1,
--bigStep = 0.01,
order = 18,
isPercent = true
},
inverse = {
type = "toggle",
width = WeakAuras.normalWidth,
name = L["Inverse"],
order = 19
},
frameRate = {
type = "range",
control = "WeakAurasSpinBox",
width = WeakAuras.normalWidth,
name = L["Frame Rate"],
min = 3,
max = 120,
step = 1,
bigStep = 3,
order = 20,
disabled = function() return data.animationType == "progress" end;
},
-- Anchor settings added below
barModelClip = {
type = "toggle",
width = WeakAuras.normalWidth,
name = L["Clipped by Foreground"],
order = 27,
hidden = function()
return not (parentData.regionType == "aurabar"
and data.anchor_mode == "area"
and data.anchor_area == "fg")
end
},
scale = {
type = "range",
control = "WeakAurasSpinBox",
width = WeakAuras.normalWidth,
name = L["Scale Factor"],
order = 28,
softMin = 0.5,
softMax = 3,
step = 0.1,
hidden = function()
if parentData.regionType == "aurabar"
and data.anchorMode == "area"
and data.anchor_area == "fg"
and data.barModelClip
then
return true
end
return data.anchor_mode ~= "area"
end
},
}
OptionsPrivate.commonOptions.PositionOptionsForSubElement(data, options, 21, areaAnchors, pointAnchors)
OptionsPrivate.AddUpDownDeleteDuplicate(options, parentData, index, "substopmotion")
return options
end
WeakAuras.RegisterSubRegionOptions("substopmotion", createOptions, L["Shows a Stop Moption"]);
@@ -23,6 +23,37 @@ local function AdjustConditions(data, replacements)
end
end
local function ReplacePrefix(hay, replacements)
for old, new in pairs(replacements) do
if hay:sub(1, #old) == old then
return new .. hay:sub(#old + 1)
end
end
end
local function AdjustAnchors(data, replacements)
if not data.subRegions then
return
end
for _, subRegionData in ipairs(data.subRegions) do
local anchor_area = subRegionData.anchor_area
if anchor_area then
local replaced = ReplacePrefix(anchor_area, replacements)
if replaced then
subRegionData.anchor_area = replaced
end
end
local anchor_point = subRegionData.anchor_point
if anchor_point then
local replaced = ReplacePrefix(anchor_point, replacements)
if replaced then
subRegionData.anchor_point = replaced
end
end
end
end
function OptionsPrivate.DeleteSubRegion(data, index, regionType)
if not data.subRegions then
return
@@ -39,6 +70,7 @@ function OptionsPrivate.DeleteSubRegion(data, index, regionType)
end
AdjustConditions(data, replacements);
AdjustAnchors(data, replacements)
WeakAuras.Add(data)
OptionsPrivate.ClearOptions(data.id)
@@ -58,6 +90,7 @@ function OptionsPrivate.MoveSubRegionUp(data, index, regionType)
}
AdjustConditions(data, replacements);
AdjustAnchors(data, replacements)
WeakAuras.Add(data)
OptionsPrivate.ClearOptions(data.id)
@@ -77,6 +110,7 @@ function OptionsPrivate.MoveSubRegionDown(data, index, regionType)
}
AdjustConditions(data, replacements);
AdjustAnchors(data, replacements)
WeakAuras.Add(data)
OptionsPrivate.ClearOptions(data.id)
@@ -95,7 +129,8 @@ function OptionsPrivate.DuplicateSubRegion(data, index, regionType)
for i = index + 1, #data.subRegions do
replacements["sub." .. i .. "."] = "sub." .. (i + 1) .. "."
end
AdjustConditions(data, replacements);
AdjustConditions(data, replacements)
AdjustAnchors(data, replacements)
WeakAuras.Add(data)
OptionsPrivate.ClearOptions(data.id)
@@ -302,7 +302,7 @@ local function createOptions(parentData, data, index, subIndex)
control = "WeakAurasExpandSmall",
name = function()
local selfPoint = data.text_selfPoint ~= "AUTO" and self_point_types[data.text_selfPoint]
local anchorPoint = anchors[data.text_anchorPoint or "CENTER"] or anchors["CENTER"]
local anchorPoint = anchors[data.anchor_point or "CENTER"] or anchors["CENTER"]
local xOffset = data.text_anchorXOffset or 0
local yOffset = data.text_anchorYOffset or 0
@@ -364,7 +364,7 @@ local function createOptions(parentData, data, index, subIndex)
hidden = hiddenFunction
}
options.text_anchorPoint = {
options.anchor_point = {
type = "select",
width = WeakAuras.normalWidth,
name = function()
+16 -1
View File
@@ -315,4 +315,19 @@ local function createOptions(parentData, data, index, subIndex)
return options
end
WeakAuras.RegisterSubRegionOptions("subtick", createOptions, L["Places a tick on the bar"]);
local getAnchors = function(data)
local anchors = {}
for i in ipairs(data.tick_placements) do
anchors["tick."..i] = {
display = L["Tick Center %s"]:format(i),
type = "point"
}
anchors["tickarea."..i] = {
display = L["Tick Area %s"]:format(i),
type = "area"
}
end
return anchors
end
WeakAuras.RegisterSubRegionOptions("subtick", createOptions, L["Places a tick on the bar"], getAnchors)
+1
View File
@@ -37,6 +37,7 @@ SubRegionOptions\Border.lua
SubRegionOptions\Glow.lua
SubRegionOptions\Tick.lua
SubRegionOptions\Model.lua
SubRegionOptions\StopMotion.lua
Cache.lua