diff --git a/WeakAuras/Conditions.lua b/WeakAuras/Conditions.lua index 627fcf3..f1298f1 100644 --- a/WeakAuras/Conditions.lua +++ b/WeakAuras/Conditions.lua @@ -91,7 +91,7 @@ local function formatValueForAssignment(vType, value, pathToCustomFunction, path return tostring(value) end return "nil" - elseif (vType == "string") then + elseif (vType == "string" or vType == "texture") then if type(value) == "string" then return string.format("%s", Private.QuotedString(value)) end @@ -154,7 +154,7 @@ local function formatValueForAssignment(vType, value, pathToCustomFunction, path end local function formatValueForCall(type, property) - if type == "bool" or type == "number" or type == "list" or type == "icon" or type == "string" + if type == "bool" or type == "number" or type == "list" or type == "icon" or type == "string" or type == "texture" or type == "progressSource" then return "propertyChanges['" .. property .. "']"; diff --git a/WeakAuras/SubRegionTypes/Tick.lua b/WeakAuras/SubRegionTypes/Tick.lua index 04c9064..4db41ea 100644 --- a/WeakAuras/SubRegionTypes/Tick.lua +++ b/WeakAuras/SubRegionTypes/Tick.lua @@ -84,6 +84,17 @@ local properties = { type = "bool", default = true, }, + tick_use_texture = { + display = L["Use Texture"], + setter = "SetUseTexture", + type = "bool", + default = true, + }, + tick_texture = { + display = L["Texture"], + setter = "SetTexture", + type = "texture" + } } local function GetProperties(parentData, data) @@ -408,6 +419,31 @@ local funcs = { end end end, + UpdateTexture = function(self) + if self.use_texture then + for _, tick in ipairs(self.ticks) do + tick:SetTexture(tick, self.tick_texture) + end + else + for _, tick in ipairs(self.ticks) do + tick:SetTexture(self.tick_color[1], self.tick_color[2], self.tick_color[3], self.tick_color[4]) + end + end + end, + SetTexture = function(self, texture) + if self.tick_texture == texture then + return + end + self.tick_texture = texture + self:UpdateTexture() + end, + SetUseTexture = function(self, use) + if self.use_texture == use then + return + end + self.use_texture = use + self:UpdateTexture() + end } local function modify(parent, region, parentData, data, first) diff --git a/WeakAurasOptions/ConditionOptions.lua b/WeakAurasOptions/ConditionOptions.lua index 200090c..08b8b4b 100644 --- a/WeakAurasOptions/ConditionOptions.lua +++ b/WeakAurasOptions/ConditionOptions.lua @@ -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", diff --git a/WeakAurasOptions/OptionsFrames/TexturePicker.lua b/WeakAurasOptions/OptionsFrames/TexturePicker.lua index 8860ae5..7cd44b7 100644 --- a/WeakAurasOptions/OptionsFrames/TexturePicker.lua +++ b/WeakAurasOptions/OptionsFrames/TexturePicker.lua @@ -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); diff --git a/WeakAurasOptions/RegionOptions/AuraBar.lua b/WeakAurasOptions/RegionOptions/AuraBar.lua index 0929ac0..abd9179 100644 --- a/WeakAurasOptions/RegionOptions/AuraBar.lua +++ b/WeakAurasOptions/RegionOptions/AuraBar.lua @@ -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", diff --git a/WeakAurasOptions/RegionOptions/ProgressTexture.lua b/WeakAurasOptions/RegionOptions/ProgressTexture.lua index 48f1302..7b0aeb5 100644 --- a/WeakAurasOptions/RegionOptions/ProgressTexture.lua +++ b/WeakAurasOptions/RegionOptions/ProgressTexture.lua @@ -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", diff --git a/WeakAurasOptions/RegionOptions/StopMotion.lua b/WeakAurasOptions/RegionOptions/StopMotion.lua index 682d709..9f5a8c4 100644 --- a/WeakAurasOptions/RegionOptions/StopMotion.lua +++ b/WeakAurasOptions/RegionOptions/StopMotion.lua @@ -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, diff --git a/WeakAurasOptions/RegionOptions/Texture.lua b/WeakAurasOptions/RegionOptions/Texture.lua index 8130d17..32ef9cb 100644 --- a/WeakAurasOptions/RegionOptions/Texture.lua +++ b/WeakAurasOptions/RegionOptions/Texture.lua @@ -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", diff --git a/WeakAurasOptions/SubRegionOptions/Tick.lua b/WeakAurasOptions/SubRegionOptions/Tick.lua index 49fb190..d2fb900 100644 --- a/WeakAurasOptions/SubRegionOptions/Tick.lua +++ b/WeakAurasOptions/SubRegionOptions/Tick.lua @@ -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" diff --git a/WeakAurasOptions/WeakAurasOptions.lua b/WeakAurasOptions/WeakAurasOptions.lua index ece4963..8f16cce 100644 --- a/WeakAurasOptions/WeakAurasOptions.lua +++ b/WeakAurasOptions/WeakAurasOptions.lua @@ -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)