From d9af2978fc3d97236816622b1a42ab4dca097ed1 Mon Sep 17 00:00:00 2001 From: Bunny67 Date: Wed, 5 Jan 2022 00:09:42 +0300 Subject: [PATCH] test desaturate --- WeakAuras/RegionTypes/AuraBar.lua | 18 ++++++++++++++++++ WeakAuras/RegionTypes/Icon.lua | 18 ++++++++++++++++++ WeakAuras/compat.lua | 21 +-------------------- 3 files changed, 37 insertions(+), 20 deletions(-) diff --git a/WeakAuras/RegionTypes/AuraBar.lua b/WeakAuras/RegionTypes/AuraBar.lua index 9e0a3be..7278f41 100644 --- a/WeakAuras/RegionTypes/AuraBar.lua +++ b/WeakAuras/RegionTypes/AuraBar.lua @@ -978,6 +978,19 @@ local funcs = { end } +local function setDesaturated(self, desaturated, ...) + self.isDesaturated = desaturated and 1 or 0 + return self._SetDesaturated(self, desaturated, ...) +end + +local function setTexture(self, ...) + local apply = self._SetTexture(self, ...) + if self.isDesaturated ~= nil then + self._SetDesaturated(self, self._isDesaturated) + end + return apply +end + -- Called when first creating a new region/display local function create(parent) -- Create overall region (containing everything else) @@ -1013,6 +1026,11 @@ local function create(parent) region.icon = icon; icon:SetTexture("Interface\\Icons\\INV_Misc_QuestionMark"); + icon._SetDesaturated = self.SetDesaturated + icon.SetDesaturated = setDesaturated + icon._SetTexture = self._SetTexture + icon.SetTexture = setTexture + -- Region variables region.values = {}; diff --git a/WeakAuras/RegionTypes/Icon.lua b/WeakAuras/RegionTypes/Icon.lua index 2555e82..b2fb59c 100644 --- a/WeakAuras/RegionTypes/Icon.lua +++ b/WeakAuras/RegionTypes/Icon.lua @@ -174,6 +174,19 @@ local function AnchorSubRegion(self, subRegion, anchorType, selfPoint, anchorPoi end end +local function setDesaturated(self, desaturated, ...) + self.isDesaturated = desaturated and 1 or 0 + return self._SetDesaturated(self, desaturated, ...) +end + +local function setTexture(self, ...) + local apply = self._SetTexture(self, ...) + if self.isDesaturated ~= nil then + self._SetDesaturated(self, self._isDesaturated) + end + return apply +end + local function create(parent, data) local font = "GameFontHighlight"; @@ -226,6 +239,11 @@ local function create(parent, data) region.icon = icon; icon:SetTexture("Interface\\Icons\\INV_Misc_QuestionMark"); + icon._SetDesaturated = self.SetDesaturated + icon.SetDesaturated = setDesaturated + icon._SetTexture = self._SetTexture + icon.SetTexture = setTexture + --This section creates a unique frame id for the cooldown frame so that it can be created with a global reference --The reason is so that WeakAuras cooldown frames can interact properly with OmniCC (i.e., put on its ignore list for timer overlays) local id = data.id; diff --git a/WeakAuras/compat.lua b/WeakAuras/compat.lua index 9af1a27..9801e0c 100644 --- a/WeakAuras/compat.lua +++ b/WeakAuras/compat.lua @@ -143,23 +143,4 @@ if not SmoothStatusBarMixin then self.lastSmoothedMin = min; self.lastSmoothedMax = max; end -end - -do - local texture_mt = getmetatable(CreateFrame("Frame"):CreateTexture()).__index - - local setDesaturated = texture_mt.SetDesaturated - texture_mt.SetDesaturated = function(self, desaturated, ...) - self._isDesaturated = desaturated - return setDesaturated(self, desaturated, ...) - end - - local setTexture = texture_mt.SetTexture - texture_mt.SetTexture = function(self, ...) - local isDesaturated = self._isDesaturated - local apply = setTexture(self, ...) - self:SetDesaturated(isDesaturated) - return apply - end -end - +end \ No newline at end of file