from retail

This commit is contained in:
Bunny67
2022-05-19 22:04:17 +03:00
parent 9465daedd8
commit e7e789686a
86 changed files with 9118 additions and 5486 deletions
+24 -30
View File
@@ -178,12 +178,8 @@ local function createOptions(id, data)
func = function()
local path = {"displayIcon"}
local paths = {}
if data.controlledChildren then
for i, childId in pairs(data.controlledChildren) do
paths[childId] = path
end
else
paths[data.id] = path
for child in OptionsPrivate.Private.TraverseLeafsOrAura(data) do
paths[child.id] = path
end
OptionsPrivate.OpenIconPicker(data, paths)
end,
@@ -393,12 +389,32 @@ local function createOptions(id, data)
}
local index = 0.01
for id, display in ipairs(overlayInfo) do
options["overlaytexture" .. id] = {
type = "select",
dialogControl = "LSM30_Statusbar",
width = WeakAuras.doubleWidth,
name = string.format(L["%s Texture"], display),
values = AceGUIWidgetLSMlists.statusbar,
order = 58.1 + index,
set = function(info, texture)
if (not data.overlaysTexture) then
data.overlaysTexture = {};
end
data.overlaysTexture[id] = texture;
WeakAuras.Add(data);
end,
get = function()
if data.overlaysTexture and data.overlaysTexture[id] then
return data.overlaysTexture[id]
end
end
}
options["overlaycolor" .. id] = {
type = "color",
width = WeakAuras.normalWidth,
name = string.format(L["%s Color"], display),
hasAlpha = true,
order = 58 + index,
order = 58.2 + index,
get = function()
if (data.overlays and data.overlays[id]) then
return unpack(data.overlays[id]);
@@ -420,7 +436,7 @@ local function createOptions(id, data)
type = "toggle",
width = WeakAuras.normalWidth,
name = L["Clip Overlays"],
order = 58 + index;
order = 58.3 + index;
}
end
@@ -770,27 +786,5 @@ local function GetAnchors(data)
return anchorPoints;
end
local function subCreateOptions(parentData, data, index, subIndex)
local order = 9
local options = {
__title = L["Foreground"],
__order = 1,
__up = function()
if (OptionsPrivate.Private.ApplyToDataOrChildData(parentData, OptionsPrivate.MoveSubRegionUp, index, "aurabar_bar")) then
WeakAuras.ClearAndUpdateOptions(parentData.id)
end
end,
__down = function()
if (OptionsPrivate.Private.ApplyToDataOrChildData(parentData, OptionsPrivate.MoveSubRegionDown, index, "aurabar_bar")) then
WeakAuras.ClearAndUpdateOptions(parentData.id)
end
end,
__notcollapsable = true
}
return options
end
-- Register new region type options with WeakAuras
WeakAuras.RegisterRegionOptions("aurabar", createOptions, createIcon, L["Progress Bar"], createThumbnail, modifyThumbnail, L["Shows a progress bar with name, timer, and icon"], templates, GetAnchors);
WeakAuras.RegisterSubRegionOptions("aurabar_bar", subCreateOptions, L["Foreground"]);
@@ -134,12 +134,7 @@ local function createOptions(id, data)
order = 1.5,
width = WeakAuras.normalWidth,
name = L["Group by Frame"],
desc = L[
[[Group and anchor each auras by frame.
- Unit Frames: attach to unit frame buttons per unit.
- Custom Frames: choose which frame each region should be anchored to.]]
],
desc = L["Group and anchor each auras by frame.\n\n- Unit Frames: attach to unit frame buttons per unit.\n- Custom Frames: choose which frame each region should be anchored to."],
hidden = function() return data.grow == "CUSTOM" end,
},
anchorPerUnit = {
+67 -36
View File
@@ -54,40 +54,8 @@ local function getWidth(data, region)
end
end
-- Create region options table
local function createOptions(id, data)
-- Region options
local options = {
__title = L["Group Settings"],
__order = 1,
groupIcon = {
type = "input",
width = WeakAuras.doubleWidth - 0.15,
name = L["Group Icon"],
desc = L["Set Thumbnail Icon"],
order = 0.50,
get = function()
return data.groupIcon and tostring(data.groupIcon) or ""
end,
set = function(info, v)
data.groupIcon = v
WeakAuras.Add(data)
WeakAuras.UpdateThumbnail(data)
end
},
chooseIcon = {
type = "execute",
width = 0.15,
name = L["Choose"],
order = 0.51,
func = function()
OptionsPrivate.OpenIconPicker(data, { [data.id] = {"groupIcon"} }, true)
end,
imageWidth = 24,
imageHeight = 24,
control = "WeakAurasIcon",
image = "Interface\\AddOns\\WeakAuras\\Media\\Textures\\browse",
},
local function createDistributeAlignOptions(id, data)
return {
align_h = {
type = "select",
width = WeakAuras.normalWidth,
@@ -551,7 +519,45 @@ local function createOptions(id, data)
WeakAuras.Add(data);
OptionsPrivate.ResetMoverSizer();
end
}
}
end
-- Create region options table
local function createOptions(id, data)
-- Region options
local options = {
__title = L["Group Settings"],
__order = 1,
groupIcon = {
type = "input",
width = WeakAuras.doubleWidth - 0.15,
name = L["Group Icon"],
desc = L["Set Thumbnail Icon"],
order = 0.50,
get = function()
return data.groupIcon and tostring(data.groupIcon) or ""
end,
set = function(info, v)
data.groupIcon = v
WeakAuras.Add(data)
WeakAuras.UpdateThumbnail(data)
end
},
chooseIcon = {
type = "execute",
width = 0.15,
name = L["Choose"],
order = 0.51,
func = function()
OptionsPrivate.OpenIconPicker(data, { [data.id] = {"groupIcon"} }, true)
end,
imageWidth = 24,
imageHeight = 24,
control = "WeakAurasIcon",
image = "Interface\\AddOns\\WeakAuras\\Media\\Textures\\browse",
},
-- Alignment/Distribute options are added below
scale = {
type = "range",
width = WeakAuras.normalWidth,
@@ -581,8 +587,33 @@ local function createOptions(id, data)
},
};
for k, v in pairs(OptionsPrivate.commonOptions.BorderOptions(id, data, nil, nil, 70)) do
options[k] = v
local hasSubGroups = false
local hasDynamicSubGroup = false
for index, childId in pairs(data.controlledChildren) do
local childData = WeakAuras.GetData(childId);
if childData.controlledChildren then
hasSubGroups = true
end
if childData.regionType == "dynamicgroup" then
hasDynamicSubGroup = true
end
if hasSubGroups and hasDynamicSubGroup then
break
end
end
if not hasSubGroups then
for k, v in pairs(createDistributeAlignOptions(id, data)) do
options[k] = v
end
end
if not hasDynamicSubGroup then
for k, v in pairs(OptionsPrivate.commonOptions.BorderOptions(id, data, nil, nil, 70)) do
options[k] = v
end
end
return {
+9 -10
View File
@@ -55,12 +55,8 @@ local function createOptions(id, data)
func = function()
local path = {"displayIcon"}
local paths = {}
if data.controlledChildren then
for i, childId in pairs(data.controlledChildren) do
paths[childId] = path
end
else
paths[data.id] = path
for child in OptionsPrivate.Private.TraverseLeafsOrAura(data) do
paths[child.id] = path
end
OptionsPrivate.OpenIconPicker(data, paths)
end,
@@ -188,13 +184,14 @@ local function createOptions(id, data)
cooldownHeader = {
type = "header",
order = 11,
name = L["Cooldown Settings"],
name = L["Swipe Overlay Settings"],
},
cooldown = {
type = "toggle",
width = WeakAuras.normalWidth,
name = L["Show Cooldown"],
name = L["Enable Swipe"],
order = 11.1,
desc = L["Enable the \"Swipe\" radial overlay"],
disabled = function() return not OptionsPrivate.Private.CanHaveDuration(data); end,
get = function() return OptionsPrivate.Private.CanHaveDuration(data) and data.cooldown; end
},
@@ -203,6 +200,7 @@ local function createOptions(id, data)
width = WeakAuras.normalWidth,
name = L["Inverse"],
order = 11.2,
desc = L["Invert the direction of progress"],
disabled = function() return not (OptionsPrivate.Private.CanHaveDuration(data) and data.cooldown); end,
get = function() return data.inverse and OptionsPrivate.Private.CanHaveDuration(data) and data.cooldown; end,
hidden = function() return not data.cooldown end
@@ -210,8 +208,9 @@ local function createOptions(id, data)
cooldownEdge = {
type = "toggle",
width = WeakAuras.normalWidth,
name = L["Cooldown Edge"],
order = 11.3,
name = L["Show \"Edge\""],
order = 11.4,
desc = "|TInterface\\AddOns\\WeakAuras\\Media\\Textures\\edge-example:30|t\n"..L["Enable \"Edge\" part of the overlay"],
disabled = function() return not OptionsPrivate.Private.CanHaveDuration(data) end,
hidden = function() return not data.cooldown end,
},
+2 -2
View File
@@ -42,7 +42,7 @@ local function createOptions(id, data)
width = WeakAuras.normalWidth,
name = L["Animation Sequence"],
min = 0,
max = 150,
softMax = 150,
step = 1,
bigStep = 1,
order = 6,
@@ -106,7 +106,7 @@ local function createOptions(id, data)
else
options.model_path = {
type = "input",
width = WeakAuras.doubleWidth,
width = WeakAuras.doubleWidth - 0.15,
name = L["Model"],
order = 1
}
@@ -189,12 +189,6 @@ local function createOptions(id, data)
data.crop_x = v;
WeakAuras.Add(data);
WeakAuras.UpdateThumbnail(data);
if(data.parent) then
local parentData = WeakAuras.GetData(data.parent);
if(parentData) then
WeakAuras.Add(parentData);
end
end
OptionsPrivate.ResetMoverSizer();
end,
},
@@ -212,12 +206,6 @@ local function createOptions(id, data)
data.crop_y = v;
WeakAuras.Add(data);
WeakAuras.UpdateThumbnail(data);
if(data.parent) then
local parentData = WeakAuras.GetData(data.parent);
if(parentData) then
WeakAuras.Add(parentData);
end
end
OptionsPrivate.ResetMoverSizer();
end,
},
@@ -240,18 +228,25 @@ local function createOptions(id, data)
bigStep = 0.01,
isPercent = true
},
smoothProgress = {
type = "toggle",
width = WeakAuras.normalWidth,
name = L["Smooth Progress"],
desc = L["Animates progress changes"],
order = 55.1
},
slanted = {
type = "toggle",
width = WeakAuras.normalWidth,
name = L["Slanted"],
order = 55.2,
order = 55.3,
hidden = function() return data.orientation == "CLOCKWISE" or data.orientation == "ANTICLOCKWISE"; end
},
slant = {
type = "range",
width = WeakAuras.normalWidth,
name = L["Slant Amount"],
order = 55.3,
order = 55.4,
min = 0,
max = 1,
bigStep = 0.1,
@@ -261,14 +256,14 @@ local function createOptions(id, data)
type = "toggle",
width = WeakAuras.normalWidth,
name = L["Inverse Slant"],
order = 55.4,
order = 55.5,
hidden = function() return not data.slanted or data.orientation == "CLOCKWISE" or data.orientation == "ANTICLOCKWISE" end
},
slantMode = {
type = "select",
width = WeakAuras.normalWidth,
name = L["Slant Mode"],
order = 55.5,
order = 55.6,
hidden = function() return not data.slanted or data.orientation == "CLOCKWISE" or data.orientation == "ANTICLOCKWISE" end,
values = OptionsPrivate.Private.slant_mode
},
@@ -413,11 +408,11 @@ local function createThumbnail()
local background = region:CreateTexture(nil, "BACKGROUND");
borderframe.background = background;
local foreground = region:CreateTexture(nil, "ART");
local foreground = region:CreateTexture(nil, "ARTWORK");
borderframe.foreground = foreground;
borderframe.foregroundSpinner = WeakAuras.createSpinner(region, "ARTWORK", region:GetFrameLevel() + 2);
borderframe.backgroundSpinner = WeakAuras.createSpinner(region, "BACKGROUND", region:GetFrameLevel() + 1);
borderframe.foregroundSpinner = WeakAuras.createSpinner(region, "ARTWORK", region:GetFrameLevel() + 2);
return borderframe;
end
@@ -792,8 +787,4 @@ local templates = {
},
}
local function GetAnchors(data)
return OptionsPrivate.Private.default_types_for_anchor
end
WeakAuras.RegisterRegionOptions("progresstexture", createOptions, createIcon, L["Progress Texture"], createThumbnail, modifyThumbnail, L["Shows a texture that changes based on duration"], templates, GetAnchors);
WeakAuras.RegisterRegionOptions("progresstexture", createOptions, createIcon, L["Progress Texture"], createThumbnail, modifyThumbnail, L["Shows a texture that changes based on duration"], templates);
+444 -198
View File
@@ -8,34 +8,74 @@ 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);
setTile(textureWidget, data.count, data.rows, data.columns, data.frameScaleW or 1, data.frameScaleH or 1);
textureWidget:SetOnUpdate(function()
textureWidget.frameNr = textureWidget.frameNr + 1;
if (textureWidget.frameNr == data.count) then
textureWidget.frameNr = 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
setTile(textureWidget, textureWidget.frameNr, data.rows, data.columns);
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()
textureWidget.frameNr = textureWidget.frameNr + 1;
if (textureWidget.frameNr == data.count) then
textureWidget.frameNr = 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
local texture = texturePath .. format("%03d", textureWidget.frameNr)
textureWidget:SetTexture(texture, textureName);
end);
end
else
@@ -45,9 +85,16 @@ local function setTextureFunc(textureWidget, texturePath, textureName)
end
local function textureNameHasData(textureName)
local pattern = "%.x(%d+)y(%d+)f(%d+)%.[tb][gl][ap]"
local rows, columns, frames = textureName:lower():match(pattern)
return rows and columns and frames
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)
@@ -56,7 +103,7 @@ local function createOptions(id, data)
__order = 1,
foregroundTexture = {
type = "input",
width = WeakAuras.normalWidth - 0.15,
width = WeakAuras.doubleWidth - 0.15,
name = L["Texture"],
order = 1,
},
@@ -79,169 +126,157 @@ local function createOptions(id, data)
control = "WeakAurasIcon",
image = "Interface\\AddOns\\WeakAuras\\Media\\Textures\\browse",
},
backgroundTexture = {
type = "input",
width = WeakAuras.normalWidth - 0.15,
name = L["Background Texture"],
order = 5,
disabled = function() return data.sameTexture or data.hideBackground end,
get = function() return data.sameTexture and data.foregroundTexture or data.backgroundTexture; end,
},
chooseBackgroundTexture = {
type = "execute",
width = 0.15,
name = L["Choose"],
order = 6,
func = function()
OptionsPrivate.OpenTexturePicker(data, {}, {
texture = "backgroundTexture",
color = "backgroundColor",
rotation = "rotation",
mirror = "mirror",
blendMode = "blendMode"
}, texture_types, setTextureFunc);
end,
disabled = function() return data.sameTexture or data.hideBackground; end,
imageWidth = 24,
imageHeight = 24,
control = "WeakAurasIcon",
image = "Interface\\AddOns\\WeakAuras\\Media\\Textures\\browse",
},
sameTextureSpace = {
type = "description",
width = WeakAuras.normalWidth,
name = "",
order = 13,
},
hideBackground = {
type = "toggle",
name = L["Hide"],
order = 14,
width = WeakAuras.halfWidth,
},
sameTexture = {
type = "toggle",
width = WeakAuras.halfWidth,
name = L["Same"],
order = 15,
disabled = function() return data.hideBackground; end
foregroundColor = {
type = "color",
width = WeakAuras.normalWidth,
name = L["Color"],
hasAlpha = true,
order = 3
},
desaturateForeground = {
type = "toggle",
width = WeakAuras.normalWidth,
name = L["Desaturate"],
order = 17.5,
},
desaturateBackground = {
type = "toggle",
name = L["Desaturate"],
order = 17.6,
width = WeakAuras.normalWidth,
disabled = function() return data.hideBackground; end
},
-- Foreground options for custom textures
customForegroundHeader = {
type = "header",
name = L["Custom Foreground"],
order = 17.70,
hidden = function() return texture_data[data.foregroundTexture] or textureNameHasData(data.foregroundTexture) end
type = "toggle",
width = WeakAuras.normalWidth,
name = L["Desaturate"],
order = 3.5,
},
customForegroundRows = {
type = "range",
width = WeakAuras.normalWidth,
type = "input",
width = WeakAuras.doubleWidth / 3,
name = L["Rows"],
min = 1,
max = 64,
order = 17.71,
validate = WeakAuras.ValidateNumeric,
get = function()
return data.customForegroundRows and tostring(data.customForegroundRows) or "";
end,
set = function(info, v)
data.customForegroundRows = v and tonumber(v) or 0
WeakAuras.Add(data);
WeakAuras.UpdateThumbnail(data);
end,
order = 4,
hidden = function() return texture_data[data.foregroundTexture] or textureNameHasData(data.foregroundTexture) end
},
customForegroundColumns = {
type = "range",
width = WeakAuras.normalWidth,
type = "input",
width = WeakAuras.doubleWidth / 3,
name = L["Columns"],
min = 1,
max = 64,
order = 17.72,
validate = WeakAuras.ValidateNumeric,
get = function()
return data.customForegroundColumns and tostring(data.customForegroundColumns) or "";
end,
set = function(info, v)
data.customForegroundColumns = v and tonumber(v) or 0
WeakAuras.Add(data);
WeakAuras.UpdateThumbnail(data);
end,
order = 5,
hidden = function() return texture_data[data.foregroundTexture] or textureNameHasData(data.foregroundTexture) end
},
customForegroundFrames = {
type = "range",
width = WeakAuras.normalWidth,
type = "input",
width = WeakAuras.doubleWidth / 3,
name = L["Frame Count"],
min = 0,
max = 4096,
--bigStep = 0.01,
order = 17.73,
validate = WeakAuras.ValidateNumeric,
get = function()
return data.customForegroundFrames and tostring(data.customForegroundFrames) or "";
end,
set = function(info, v)
data.customForegroundFrames = v and tonumber(v) or 0
WeakAuras.Add(data);
WeakAuras.UpdateThumbnail(data);
end,
order = 6,
hidden = function() return texture_data[data.foregroundTexture] or textureNameHasData(data.foregroundTexture) end
},
customForegroundSpace = {
type = "execute",
width = WeakAuras.normalWidth,
name = "",
order = 17.74,
image = function() return "", 0, 0 end,
hidden = function() return texture_data[data.foregroundTexture] or textureNameHasData(data.foregroundTexture) end
customForegroundFileWidth = {
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.customForegroundFileWidth and tostring(data.customForegroundFileWidth) or "";
end,
set = function(info, v)
data.customForegroundFileWidth = v and tonumber(v) or 0
WeakAuras.Add(data);
WeakAuras.UpdateThumbnail(data);
end,
order = 7,
hidden = function() return texture_data[data.foregroundTexture] or textureNameHasData(data.foregroundTexture) end
},
-- Background options for custom textures
customBackgroundHeader = {
type = "header",
name = L["Custom Background"],
order = 18.00,
hidden = function() return data.sameTexture or texture_data[data.backgroundTexture] or textureNameHasData(data.backgroundTexture)
or data.hideBackground end
customForegroundFileHeight = {
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.customForegroundFileHeight and tostring(data.customForegroundFileHeight) or "";
end,
set = function(info, v)
data.customForegroundFileHeight = v and tonumber(v) or 0
WeakAuras.Add(data);
WeakAuras.UpdateThumbnail(data);
end,
order = 8,
hidden = function() return texture_data[data.foregroundTexture] or textureNameHasData(data.foregroundTexture) end
},
customBackgroundRows = {
type = "range",
width = WeakAuras.normalWidth,
name = L["Rows"],
min = 1,
max = 64,
order = 18.01,
hidden = function() return data.sameTexture or texture_data[data.backgroundTexture] or textureNameHasData(data.backgroundTexture)
or data.hideBackground end
customForegroundFrameWidth = {
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.customForegroundFrameWidth and tostring(data.customForegroundFrameWidth) or "";
end,
set = function(info, v)
data.customForegroundFrameWidth = v and tonumber(v) or 0
WeakAuras.Add(data);
WeakAuras.UpdateThumbnail(data);
end,
order = 9,
hidden = function() return texture_data[data.foregroundTexture] or textureNameHasData(data.foregroundTexture) end
},
customBackgroundColumns = {
type = "range",
width = WeakAuras.normalWidth,
name = L["Columns"],
min = 1,
max = 64,
order = 18.02,
hidden = function() return data.sameTexture or texture_data[data.backgroundTexture] or textureNameHasData(data.backgroundTexture)
or data.hideBackground end
},
customBackgroundFrames = {
type = "range",
width = WeakAuras.normalWidth,
name = L["Frame Count"],
min = 0,
max = 4096,
step = 1,
order = 18.03,
hidden = function() return data.sameTexture or texture_data[data.backgroundTexture] or textureNameHasData(data.backgroundTexture)
or data.hideBackground end
},
customBackgroundSpace = {
type = "execute",
width = WeakAuras.normalWidth,
name = "",
order = 18.04,
image = function() return "", 0, 0 end,
hidden = function() return data.sameTexture or texture_data[data.backgroundTexture] or textureNameHasData(data.backgroundTexture)
or data.hideBackground end
customForegroundFrameHeight = {
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.customForegroundFrameHeight and tostring(data.customForegroundFrameHeight) or "";
end,
set = function(info, v)
data.customForegroundFrameHeight = v and tonumber(v) or 0
WeakAuras.Add(data);
WeakAuras.UpdateThumbnail(data);
end,
order = 10,
hidden = function() return texture_data[data.foregroundTexture] or textureNameHasData(data.foregroundTexture) end
},
blendMode = {
type = "select",
width = WeakAuras.normalWidth,
name = L["Blend Mode"],
order = 20,
order = 11,
values = OptionsPrivate.Private.blend_types
},
animationType = {
type = "select",
width = WeakAuras.normalWidth,
name = L["Animation Mode"],
order = 21,
order = 12,
values = animation_types
},
startPercent = {
@@ -251,7 +286,7 @@ local function createOptions(id, data)
min = 0,
max = 1,
--bigStep = 0.01,
order = 22,
order = 13,
isPercent = true
},
endPercent = {
@@ -261,7 +296,7 @@ local function createOptions(id, data)
min = 0,
max = 1,
--bigStep = 0.01,
order = 23,
order = 14,
isPercent = true
},
frameRate = {
@@ -272,47 +307,225 @@ local function createOptions(id, data)
max = 120,
step = 1,
bigStep = 3,
order = 24,
order = 15,
disabled = function() return data.animationType == "progress" end;
},
backgroundPercent = {
type = "range",
width = WeakAuras.normalWidth,
name = L["Background"],
min = 0,
max = 1,
order = 25,
isPercent = true,
disabled = function() return data.hideBackground; end
inverse = {
type = "toggle",
width = WeakAuras.normalWidth,
name = L["Inverse"],
order = 15.5
},
foregroundColor = {
type = "color",
width = WeakAuras.normalWidth,
name = L["Foreground Color"],
hasAlpha = true,
order = 30
customBackgroundHeader = {
type = "header",
name = L["Background Texture"],
order = 16,
},
hideBackground = {
type = "toggle",
name = L["Hide Background"],
order = 17,
width = WeakAuras.normalWidth,
},
sameTexture = {
type = "toggle",
width = WeakAuras.normalWidth,
name = L["Same texture as Foreground"],
order = 18,
disabled = function() return data.hideBackground; end,
hidden = function() return data.hideBackground; end
},
backgroundTexture = {
type = "input",
width = WeakAuras.doubleWidth - 0.15,
name = L["Background Texture"],
order = 19,
disabled = function() return data.sameTexture or data.hideBackground end,
hidden = function() return data.hideBackground end,
get = function() return data.sameTexture and data.foregroundTexture or data.backgroundTexture; end,
},
chooseBackgroundTexture = {
type = "execute",
width = 0.15,
name = L["Choose"],
order = 20,
func = function()
OptionsPrivate.OpenTexturePicker(data, {}, {
texture = "backgroundTexture",
color = "backgroundColor",
rotation = "rotation",
mirror = "mirror",
blendMode = "blendMode"
}, texture_types, setTextureFunc);
end,
disabled = function() return data.sameTexture or data.hideBackground; end,
hidden = function() return data.hideBackground end,
imageWidth = 24,
imageHeight = 24,
control = "WeakAurasIcon",
image = "Interface\\AddOns\\WeakAuras\\Media\\Textures\\browse",
},
backgroundColor = {
type = "color",
width = WeakAuras.normalWidth,
name = L["Background Color"],
name = L["Color"],
hasAlpha = true,
order = 32,
disabled = function() return data.hideBackground; end
order = 21,
disabled = function() return data.hideBackground; end,
hidden = function() return data.hideBackground; end
},
inverse = {
type = "toggle",
width = WeakAuras.normalWidth,
name = L["Inverse"],
order = 33
},
space3 = {
type = "execute",
width = WeakAuras.normalWidth,
name = "",
order = 36,
image = function() return "", 0, 0 end,
desaturateBackground = {
type = "toggle",
name = L["Desaturate"],
order = 22,
width = WeakAuras.normalWidth,
disabled = function() return data.hideBackground; end,
hidden = function() return data.hideBackground; end
},
backgroundColorHiddenSpacer = {
type = "execute",
width = WeakAuras.normalWidth,
name = "",
order = 23,
image = function() return "", 0, 0 end,
hidden = function() return not data.hideBackground end
},
customBackgroundRows = {
type = "input",
width = WeakAuras.doubleWidth / 3,
name = L["Rows"],
validate = WeakAuras.ValidateNumeric,
get = function()
return data.customBackgroundRows and tostring(data.customBackgroundRows) or "";
end,
set = function(info, v)
data.customBackgroundRows = v and tonumber(v) or 0
WeakAuras.Add(data);
WeakAuras.UpdateThumbnail(data);
end,
order = 24,
hidden = function() return data.sameTexture or texture_data[data.backgroundTexture] or textureNameHasData(data.backgroundTexture) end
},
customBackgroundColumns = {
type = "input",
width = WeakAuras.doubleWidth / 3,
name = L["Columns"],
validate = WeakAuras.ValidateNumeric,
get = function()
return data.customBackgroundColumns and tostring(data.customBackgroundColumns) or "";
end,
set = function(info, v)
data.customBackgroundColumns = v and tonumber(v) or 0
WeakAuras.Add(data);
WeakAuras.UpdateThumbnail(data);
end,
order = 25,
hidden = function() return data.sameTexture or texture_data[data.backgroundTexture] or textureNameHasData(data.backgroundTexture) end
},
customBackgroundFrames = {
type = "input",
width = WeakAuras.doubleWidth / 3,
name = L["Frame Count"],
validate = WeakAuras.ValidateNumeric,
get = function()
return data.customBackgroundFrames and tostring(data.customBackgroundFrames) or "";
end,
set = function(info, v)
data.customBackgroundFrames = v and tonumber(v) or 0
WeakAuras.Add(data);
WeakAuras.UpdateThumbnail(data);
end,
order = 26,
hidden = function() return data.sameTexture or texture_data[data.backgroundTexture] or textureNameHasData(data.backgroundTexture) end
},
customBackgroundFileWidth = {
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.customBackgroundFileWidth and tostring(data.customBackgroundFileWidth) or "";
end,
set = function(info, v)
data.customBackgroundFileWidth = v and tonumber(v) or 0
WeakAuras.Add(data);
WeakAuras.UpdateThumbnail(data);
end,
order = 27,
hidden = function() return data.sameTexture or texture_data[data.backgroundTexture] or textureNameHasData(data.backgroundTexture) end
},
customBackgroundFileHeight = {
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.customBackgroundFileHeight and tostring(data.customBackgroundFileHeight) or "";
end,
set = function(info, v)
data.customBackgroundFileHeight = v and tonumber(v) or 0
WeakAuras.Add(data);
WeakAuras.UpdateThumbnail(data);
end,
order = 28,
hidden = function() return data.sameTexture or texture_data[data.backgroundTexture] or textureNameHasData(data.backgroundTexture) end
},
customBackgroundFrameWidth = {
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.customBackgroundFrameWidth and tostring(data.customBackgroundFrameWidth) or "";
end,
set = function(info, v)
data.customBackgroundFrameWidth = v and tonumber(v) or 0
WeakAuras.Add(data);
WeakAuras.UpdateThumbnail(data);
end,
order = 29,
hidden = function() return data.sameTexture or texture_data[data.backgroundTexture] or textureNameHasData(data.backgroundTexture) end
},
customBackgroundFrameHeight = {
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.customBackgroundFrameHeight and tostring(data.customBackgroundFrameHeight) or "";
end,
set = function(info, v)
data.customBackgroundFrameHeight = v and tonumber(v) or 0
WeakAuras.Add(data);
WeakAuras.UpdateThumbnail(data);
end,
order = 30,
hidden = function() return data.sameTexture or texture_data[data.backgroundTexture] or textureNameHasData(data.backgroundTexture) end
},
backgroundPercent = {
type = "range",
width = WeakAuras.normalWidth,
name = L["Selected Frame"],
min = 0,
max = 1,
order = 31,
isPercent = true,
hidden = function() return data.hideBackground; end
}
};
if OptionsPrivate.commonOptions then
@@ -361,29 +574,55 @@ local function modifyThumbnail(parent, region, data, fullModify, size)
end
local frame = 1;
region.foreground = region.foreground or {}
local tdata = texture_data[data.foregroundTexture];
if (tdata) then
local lastFrame = tdata.count - 1;
region.startFrame = floor( (data.startPercent or 0) * lastFrame) + 1;
region.endFrame = floor( (data.endPercent or 1) * lastFrame) + 1;
region.foregroundRows = tdata.rows;
region.foregroundColumns = tdata.columns;
region.foreground.rows = tdata.rows;
region.foreground.columns = tdata.columns;
region.foreground.fileWidth = 0
region.foreground.fileHeight = 0
region.foreground.frameWidth = 0
region.foreground.frameHeight = 0
else
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 = data.foregroundTexture:lower():match(pattern)
if rows and columns and frames then
if rows then
local lastFrame = frames - 1;
region.startFrame = floor( (data.startPercent or 0) * lastFrame) + 1;
region.endFrame = floor( (data.endPercent or 1) * lastFrame) + 1;
region.foregroundRows = rows;
region.foregroundColumns = columns;
region.foreground.rows = tonumber(rows);
region.foreground.columns = tonumber(columns);
region.foreground.fileWidth = 0
region.foreground.fileHeight = 0
region.foreground.frameWidth = 0
region.foreground.frameHeight = 0
else
local lastFrame = data.customForegroundFrames - 1;
region.startFrame = floor( (data.startPercent or 0) * lastFrame) + 1;
region.endFrame = floor( (data.endPercent or 1) * lastFrame) + 1;
region.foregroundRows = data.customForegroundRows;
region.foregroundColumns = data.customForegroundColumns;
local rows, columns, frames, frameWidth, frameHeight, fileWidth, fileHeight = data.foregroundTexture:match(pattern2)
if rows then
local lastFrame = frames - 1;
region.startFrame = floor( (data.startPercent or 0) * lastFrame) + 1;
region.endFrame = floor( (data.endPercent or 1) * lastFrame) + 1;
region.foreground.rows = tonumber(rows)
region.foreground.columns = tonumber(columns)
region.foreground.fileWidth = tonumber(fileWidth)
region.foreground.fileHeight = tonumber(fileHeight)
region.foreground.frameWidth = tonumber(frameWidth)
region.foreground.frameHeight = tonumber(frameHeight)
else
local lastFrame = data.customForegroundFrames - 1;
region.startFrame = floor( (data.startPercent or 0) * lastFrame) + 1;
region.endFrame = floor( (data.endPercent or 1) * lastFrame) + 1;
region.foreground.rows = data.customForegroundRows;
region.foreground.columns = data.customForegroundColumns;
region.foreground.fileWidth = data.customForegroundFileWidth
region.foreground.fileHeight = data.customForegroundFileHeight
region.foreground.frameWidth = data.customForegroundFrameWidth
region.foreground.frameHeight = data.customForegroundFrameHeight
end
end
end
@@ -393,13 +632,20 @@ local function modifyThumbnail(parent, region, data, fullModify, size)
local texture = data.foregroundTexture or "Interface\\AddOns\\WeakAuras\\Media\\Textures\\stopmotion";
if (region.foregroundRows and region.foregroundColumns) then
if (region.foreground.rows and region.foreground.columns) then
region.texture:SetTexture(texture);
setTile(region.texture, frame, region.foregroundRows, region.foregroundColumns);
local frameScaleW, frameScaleH = 1, 1
if region.foreground.fileWidth and region.foreground.frameWidth and region.foreground.fileWidth > 0 and region.foreground.frameWidth > 0 then
frameScaleW = (region.foreground.frameWidth * region.foreground.columns) / region.foreground.fileWidth
end
if region.foreground.fileHeight and region.foreground.frameHeight and region.foreground.fileHeight > 0 and region.foreground.frameHeight > 0 then
frameScaleH = (region.foreground.frameHeight * region.foreground.rows) / region.foreground.fileHeight
end
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.foregroundRows, region.foregroundColumns);
setTile(self.texture, frame, region.foreground.rows, region.foreground.columns, frameScaleW, frameScaleH);
end
else
region.texture:SetTexture(texture .. format("%03d", frame));
+16 -15
View File
@@ -289,22 +289,20 @@ local function createOptions(id, data)
options["displayText_format_" .. key] = option
end
if data.controlledChildren then
for index, childId in pairs(data.controlledChildren) do
local childData = WeakAuras.GetData(childId)
local get = function(key)
return childData["displayText_format_" .. key]
end
local input = childData.displayText
OptionsPrivate.AddTextFormatOption(input, true, get, addOption, hidden, setHidden, index, #data.controlledChildren)
end
else
local get = function(key)
return data["displayText_format_" .. key]
end
local input = data.displayText
OptionsPrivate.AddTextFormatOption(input, true, get, addOption, hidden, setHidden)
local total, index = 0, 1
for child in OptionsPrivate.Private.TraverseLeafsOrAura(data) do
total = total + 1
end
for child in OptionsPrivate.Private.TraverseLeafsOrAura(data) do
local get = function(key)
return child["displayText_format_" .. key]
end
local input = child.displayText
OptionsPrivate.AddTextFormatOption(input, true, get, addOption, hidden, setHidden, false, index, total)
index = index + 1
end
addOption("footer", {
type = "description",
name = "",
@@ -354,6 +352,9 @@ local function modifyThumbnail(parent, borderframe, data, fullModify, size)
local fontPath = SharedMedia:Fetch("font", data.font) or data.font;
text:SetFont(fontPath, data.fontSize < 33 and data.fontSize or 33, data.outline and "OUTLINE" or nil);
if not text:GetFont() then -- Font invalid, set the font but keep the setting
text:SetFont(STANDARD_TEXT_FONT, data.fontSize < 33 and data.fontSize or 33, data.outline and "OUTLINE" or nil);
end
text:SetTextHeight(data.fontSize);
text:SetText(data.displayText);
text:SetTextColor(data.color[1], data.color[2], data.color[3], data.color[4]);
+1 -5
View File
@@ -241,8 +241,4 @@ local templates = {
},
}
local function GetAnchors(data)
return OptionsPrivate.Private.default_types_for_anchor
end
WeakAuras.RegisterRegionOptions("texture", createOptions, createIcon, L["Texture"], createThumbnail, modifyThumbnail, L["Shows a custom texture"], templates, GetAnchors);
WeakAuras.RegisterRegionOptions("texture", createOptions, createIcon, L["Texture"], createThumbnail, modifyThumbnail, L["Shows a custom texture"], templates);