From 8973cee1cb6a82be1eb3acf9353246365b8aff71 Mon Sep 17 00:00:00 2001 From: Vollmer Date: Wed, 20 Nov 2024 14:33:39 +0100 Subject: [PATCH] add event listeners --- Widgets/Auras/Auras.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Widgets/Auras/Auras.lua b/Widgets/Auras/Auras.lua index 1c94c62..f926af7 100644 --- a/Widgets/Auras/Auras.lua +++ b/Widgets/Auras/Auras.lua @@ -205,6 +205,7 @@ end local function Icons_SetShowTempEnchant(icons, show) if icons._owner._baseUnit == "player" and icons.id == "buffs" then icons.showTempEnchant = show + icons:UpdateTempEnchantListener() end end @@ -583,10 +584,23 @@ end -- MARK: Update ------------------------------------------------- +---@param self CellAuraIcons +local function UpdateTempEnchantListener(self) + if self.showTempEnchant then + self._owner:AddEventListener("WEAPON_ENCHANT_CHANGED", self.Update, true) + self._owner:AddEventListener("WEAPON_SLOT_CHANGED", self.Update, true) + else + self._owner:RemoveEventListener("WEAPON_ENCHANT_CHANGED", self.Update) + self._owner:RemoveEventListener("WEAPON_SLOT_CHANGED", self.Update) + end +end + ---@param self CellAuraIcons local function Enable(self) self._owner:RegisterAuraCallback(self.id, self.Update) + self:UpdateTempEnchantListener() + self:Show() return true end @@ -714,6 +728,7 @@ function W:CreateAuraIcons(button, type) else auraIcons.Update = UpdateAuras_Debuffs end + auraIcons.UpdateTempEnchantListener = UpdateTempEnchantListener return auraIcons end