from retail

This commit is contained in:
NoM0Re
2025-01-22 18:23:23 +01:00
parent 23c7da5ea6
commit 674ea9fe1e
10 changed files with 137 additions and 38 deletions
+30 -1
View File
@@ -514,7 +514,7 @@ local function addControlsForChange(args, order, data, conditionVariable, totalA
args["condition" .. i .. "value" .. j].validate = WeakAuras.ValidateNumeric;
end
end
elseif (propertyType == "string") then
elseif (propertyType == "string" or propertyType == "texture") then
args["condition" .. i .. "value" .. j] = {
type = "input",
width = WeakAuras.normalWidth,
@@ -527,6 +527,35 @@ local function addControlsForChange(args, order, data, conditionVariable, totalA
set = setValue
}
order = order + 1;
if propertyType == "texture" then
args["condition" .. i .. "value" .. j].width = WeakAuras.normalWidth - 0.15
args["condition" .. i .. "value_browse" .. j] = {
type = "execute",
name = L["Choose"],
width = 0.15,
order = order,
func = function()
if data.controlledChildren then
local paths = {}
for id, reference in pairs(conditions[i].changes[j].references) do
paths[id] = {"conditions", conditions[i].check.references[id].conditionIndex, "changes", reference.changeIndex}
end
OptionsPrivate.OpenTexturePicker(data, paths,
{texture = "value"},
OptionsPrivate.Private.texture_types)
else
OptionsPrivate.OpenTexturePicker(data, {[data.id] = { "conditions", i, "changes", j } },
{texture = "value"},
OptionsPrivate.Private.texture_types)
end
end,
imageWidth = 24,
imageHeight = 24,
control = "WeakAurasIcon",
image = "Interface\\AddOns\\WeakAuras\\Media\\Textures\\browse",
}
order = order + 1;
end
elseif (propertyType == "icon") then
args["condition" .. i .. "value" .. j] = {
type = "input",
@@ -36,7 +36,7 @@ local function CompareValues(a, b)
end
end
local function GetAll(baseObject, path, property, default)
local function GetAll(baseObject, paths, property, default)
local valueFromPath = OptionsPrivate.Private.ValueFromPath
if not property then
return default
@@ -45,7 +45,7 @@ local function GetAll(baseObject, path, property, default)
local result = default
local first = true
for child in OptionsPrivate.Private.TraverseLeafsOrAura(baseObject) do
local childObject = valueFromPath(child, path)
local childObject = valueFromPath(child, paths[child.id])
if childObject and childObject[property] then
if first then
result = childObject[property]
@@ -60,10 +60,10 @@ local function GetAll(baseObject, path, property, default)
return result
end
local function SetAll(baseObject, path, property, value)
local function SetAll(baseObject, paths, property, value)
local valueFromPath = OptionsPrivate.Private.ValueFromPath
for child in OptionsPrivate.Private.TraverseLeafsOrAura(baseObject) do
local object = valueFromPath(child, path)
local object = valueFromPath(child, paths[child.id])
if object then
object[property] = value
WeakAuras.Add(child)
@@ -163,17 +163,17 @@ local function ConstructTexturePicker(frame)
wipe(group.selectedTextures)
group.selectedTextures[texturePath] = true
SetAll(self.baseObject, self.path, self.properties.texture, texturePath)
SetAll(self.baseObject, self.paths, self.properties.texture, texturePath)
group:UpdateList();
local status = dropdown.status or dropdown.localstatus
dropdown.dropdown:SetText(dropdown.list[status.selected]);
end
function group.Open(self, baseObject, path, properties, textures, SetTextureFunc)
function group.Open(self, baseObject, paths, properties, textures, SetTextureFunc)
local valueFromPath = OptionsPrivate.Private.ValueFromPath
self.baseObject = baseObject
self.path = path
self.paths = paths
self.properties = properties
self.textures = textures;
self.SetTextureFunc = SetTextureFunc
@@ -181,30 +181,32 @@ local function ConstructTexturePicker(frame)
self.selectedTextures = {}
for child in OptionsPrivate.Private.TraverseLeafsOrAura(baseObject) do
local object = valueFromPath(child, path)
local object = valueFromPath(child, paths[child.id])
if object and object[properties.texture] then
self.givenPath[child.id] = object[properties.texture]
self.selectedTextures[object[properties.texture]] = true
local texture = object[properties.texture]
self.givenPath[child.id] = texture
self.selectedTextures[texture] = true
else
self.givenPath[child.id] = ""
end
end
local colorAll = GetAll(baseObject, path, properties.color, {1, 1, 1, 1});
local colorAll = GetAll(baseObject, paths, properties.color, {1, 1, 1, 1});
self.textureData = {
r = colorAll[1] or 1,
g = colorAll[2] or 1,
b = colorAll[3] or 1,
a = colorAll[4] or 1,
rotate = GetAll(baseObject, path, properties.rotate, true),
discrete_rotation = GetAll(baseObject, path, properties.discrete_rotation, 0),
rotation = GetAll(baseObject, path, properties.rotation, 0),
mirror = GetAll(baseObject, path, properties.mirror, false),
blendMode = GetAll(baseObject, path, properties.blendMode, "ADD")
rotate = GetAll(baseObject, paths, properties.rotate, true),
discrete_rotation = GetAll(baseObject, paths, properties.discrete_rotation, 0),
rotation = GetAll(baseObject, paths, properties.rotation, 0),
mirror = GetAll(baseObject, paths, properties.mirror, false),
blendMode = GetAll(baseObject, paths, properties.blendMode, "ADD")
}
frame.window = "texture";
frame:UpdateFrameVisible()
group:UpdateList()
local _, givenPath = next(self.givenPath)
local picked = false;
for categoryName, category in pairs(self.textures) do
if not(picked) then
@@ -234,7 +236,7 @@ local function ConstructTexturePicker(frame)
function group.CancelClose()
local valueFromPath = OptionsPrivate.Private.ValueFromPath
for child in OptionsPrivate.Private.TraverseLeafsOrAura(group.baseObject) do
local childObject = valueFromPath(child, group.path)
local childObject = valueFromPath(child, group.paths[child.id])
if childObject then
childObject[group.properties.texture] = group.givenPath[child.id]
WeakAuras.Add(child);
+6 -1
View File
@@ -242,7 +242,12 @@ local function createOptions(id, data)
width = 0.15,
order = 44.1,
func = function()
OptionsPrivate.OpenTexturePicker(data, {}, {
local path = {}
local paths = {}
for child in OptionsPrivate.Private.TraverseLeafsOrAura(data) do
paths[child.id] = path
end
OptionsPrivate.OpenTexturePicker(data, paths, {
texture = "sparkTexture",
color = "sparkColor",
rotation = "sparkRotation",
@@ -19,7 +19,12 @@ local function createOptions(id, data)
width = 0.15,
order = 2,
func = function()
OptionsPrivate.OpenTexturePicker(data, {}, {
local path = {}
local paths = {}
for child in OptionsPrivate.Private.TraverseLeafsOrAura(data) do
paths[child.id] = path
end
OptionsPrivate.OpenTexturePicker(data, paths, {
texture = "foregroundTexture",
color = "foregroundColor",
rotation = "rotation",
@@ -46,7 +51,12 @@ local function createOptions(id, data)
width = 0.15,
order = 6,
func = function()
OptionsPrivate.OpenTexturePicker(data, {}, {
local path = {}
local paths = {}
for child in OptionsPrivate.Private.TraverseLeafsOrAura(data) do
paths[child.id] = path
end
OptionsPrivate.OpenTexturePicker(data, paths, {
texture = "backgroundTexture",
color = "backgroundColor",
rotation = "rotation",
+17 -8
View File
@@ -115,7 +115,12 @@ local function createOptions(id, data)
name = L["Choose"],
order = 2,
func = function()
OptionsPrivate.OpenTexturePicker(data, {}, {
local path = {}
local paths = {}
for child in OptionsPrivate.Private.TraverseLeafsOrAura(data) do
paths[child.id] = path
end
OptionsPrivate.OpenTexturePicker(data, paths, {
texture = "foregroundTexture",
color = "foregroundColor",
rotation = "rotation",
@@ -355,13 +360,17 @@ local function createOptions(id, data)
name = L["Choose"],
order = 20,
func = function()
OptionsPrivate.OpenTexturePicker(data, {}, {
texture = "backgroundTexture",
color = "backgroundColor",
rotation = "rotation",
mirror = "mirror",
blendMode = "blendMode"
}, texture_types, setTextureFunc);
local path = {}
local paths = {}
for child in OptionsPrivate.Private.TraverseLeafsOrAura(data) do
paths[child.id] = path
end
OptionsPrivate.OpenTexturePicker(data, paths, {
texture = "backgroundTexture",
color = "backgroundColor",
mirror = "mirror",
blendMode = "blendMode"
}, texture_types, setTextureFunc, true);
end,
disabled = function() return data.sameTexture or data.hideBackground; end,
hidden = function() return data.hideBackground end,
+6 -1
View File
@@ -19,7 +19,12 @@ local function createOptions(id, data)
width = 0.15,
order = 1.1,
func = function()
OptionsPrivate.OpenTexturePicker(data, {}, {
local path = {}
local paths = {}
for child in OptionsPrivate.Private.TraverseLeafsOrAura(data) do
paths[child.id] = path
end
OptionsPrivate.OpenTexturePicker(data, paths, {
texture = "texture",
color = "color",
rotate = "rotate",
+6 -3
View File
@@ -165,9 +165,12 @@ local function createOptions(parentData, data, index, subIndex)
width = 0.15,
order = 12.5,
func = function()
OptionsPrivate.OpenTexturePicker(parentData, {
"subRegions", index
}, {
local path = { "subRegions", index }
local paths = {}
for child in OptionsPrivate.Private.TraverseLeafsOrAura(parentData) do
paths[child.id] = path
end
OptionsPrivate.OpenTexturePicker(parentData, paths, {
texture = "tick_texture",
color = "tick_color",
blendMode = "tick_blend_mode"
+2 -2
View File
@@ -1674,8 +1674,8 @@ function WeakAuras.UpdateThumbnail(data)
button:UpdateThumbnail()
end
function OptionsPrivate.OpenTexturePicker(baseObject, path, properties, textures, SetTextureFunc)
frame.texturePicker:Open(baseObject, path, properties, textures, SetTextureFunc)
function OptionsPrivate.OpenTexturePicker(baseObject, paths, properties, textures, SetTextureFunc)
frame.texturePicker:Open(baseObject, paths, properties, textures, SetTextureFunc)
end
function OptionsPrivate.OpenIconPicker(baseObject, paths, groupIcon)