diff --git a/WeakAuras/Conditions.lua b/WeakAuras/Conditions.lua index 8a4fe245e8..6eb2725699 100644 --- a/WeakAuras/Conditions.lua +++ b/WeakAuras/Conditions.lua @@ -94,7 +94,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 @@ -164,7 +164,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 7aa7c2dbe8..b7fcaf4f43 100644 --- a/WeakAuras/SubRegionTypes/Tick.lua +++ b/WeakAuras/SubRegionTypes/Tick.lua @@ -85,6 +85,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) @@ -404,6 +415,31 @@ local funcs = { end end end, + UpdateTexture = function(self) + if self.use_texture then + for _, tick in ipairs(self.ticks) do + Private.SetTextureOrAtlas(tick, self.tick_texture, "CLAMPTOBLACKADDITIVE", "CLAMPTOBLACKADDITIVE") + end + else + for _, tick in ipairs(self.ticks) do + tick:SetColorTexture(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 1c007d5323..fbade605a4 100644 --- a/WeakAurasOptions/ConditionOptions.lua +++ b/WeakAurasOptions/ConditionOptions.lua @@ -515,7 +515,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, @@ -528,6 +528,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 1c4b0ea622..2fb6b355ba 100644 --- a/WeakAurasOptions/OptionsFrames/TexturePicker.lua +++ b/WeakAurasOptions/OptionsFrames/TexturePicker.lua @@ -37,7 +37,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 @@ -46,7 +46,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] @@ -61,10 +61,10 @@ local function GetAll(baseObject, path, property, default) return result end -local function SetAll(baseObject, path, property, value, width, height, adjustSize) +local function SetAll(baseObject, paths, property, value, width, height, adjustSize) 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 if adjustSize and width and height then @@ -255,17 +255,17 @@ local function ConstructTexturePicker(frame) wipe(group.selectedTextures) group.selectedTextures[texturePath] = true - SetAll(self.baseObject, self.path, self.properties.texture, texturePath, width, height, self.adjustSize) + SetAll(self.baseObject, self.paths, self.properties.texture, texturePath, width, height, self.adjustSize) 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, adjustSize) + function group.Open(self, baseObject, paths, properties, textures, SetTextureFunc, adjustSize) local valueFromPath = OptionsPrivate.Private.ValueFromPath self.baseObject = baseObject - self.path = path + self.paths = paths self.properties = properties self.textures = textures; self.SetTextureFunc = SetTextureFunc @@ -274,29 +274,31 @@ local function ConstructTexturePicker(frame) self.adjustSize = adjustSize 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, - auraRotation = GetAll(baseObject, path, properties.auraRotation, 0), - texRotation = GetAll(baseObject, path, properties.rotation, 0), - mirror = GetAll(baseObject, path, properties.mirror, false), - blendMode = GetAll(baseObject, path, properties.blendMode, "ADD") + auraRotation = GetAll(baseObject, paths, properties.auraRotation, 0), + texRotation = 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 @@ -327,7 +329,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 29369d279f..a3b1aa4176 100644 --- a/WeakAurasOptions/RegionOptions/AuraBar.lua +++ b/WeakAurasOptions/RegionOptions/AuraBar.lua @@ -268,7 +268,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 a308b88848..ea759af9bd 100644 --- a/WeakAurasOptions/RegionOptions/ProgressTexture.lua +++ b/WeakAurasOptions/RegionOptions/ProgressTexture.lua @@ -20,7 +20,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", texRotation = "rotation", @@ -48,7 +53,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", texRotation = "rotation", diff --git a/WeakAurasOptions/RegionOptions/StopMotion.lua b/WeakAurasOptions/RegionOptions/StopMotion.lua index 4087f324a3..0a5e65ae9f 100644 --- a/WeakAurasOptions/RegionOptions/StopMotion.lua +++ b/WeakAurasOptions/RegionOptions/StopMotion.lua @@ -125,7 +125,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", mirror = "mirror", @@ -378,12 +383,17 @@ local function createOptions(id, data) name = L["Choose"], order = 20, func = function() - OptionsPrivate.OpenTexturePicker(data, {}, { - texture = "backgroundTexture", - color = "backgroundColor", - mirror = "mirror", - blendMode = "blendMode" - }, texture_types, setTextureFunc, true); + 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 a50fe7369c..d7c278f8c0 100644 --- a/WeakAurasOptions/RegionOptions/Texture.lua +++ b/WeakAurasOptions/RegionOptions/Texture.lua @@ -24,7 +24,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", mirror = "mirror", diff --git a/WeakAurasOptions/SubRegionOptions/Tick.lua b/WeakAurasOptions/SubRegionOptions/Tick.lua index 4b8783d7ee..e250df5c88 100644 --- a/WeakAurasOptions/SubRegionOptions/Tick.lua +++ b/WeakAurasOptions/SubRegionOptions/Tick.lua @@ -167,9 +167,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 8ae9cbb63f..3591d130f9 100644 --- a/WeakAurasOptions/WeakAurasOptions.lua +++ b/WeakAurasOptions/WeakAurasOptions.lua @@ -1679,8 +1679,8 @@ function WeakAuras.UpdateThumbnail(data) button:UpdateThumbnail() end -function OptionsPrivate.OpenTexturePicker(baseObject, path, properties, textures, SetTextureFunc, adjustSize) - frame.texturePicker:Open(baseObject, path, properties, textures, SetTextureFunc, adjustSize) +function OptionsPrivate.OpenTexturePicker(baseObject, paths, properties, textures, SetTextureFunc, adjustSize) + frame.texturePicker:Open(baseObject, paths, properties, textures, SetTextureFunc, adjustSize) end function OptionsPrivate.OpenIconPicker(baseObject, paths, groupIcon)