From 82af623c08c2e219df3697f8895e0f234ce4f1eb Mon Sep 17 00:00:00 2001 From: Hendrik Leppkes Date: Sun, 9 Nov 2008 13:28:00 +0100 Subject: [PATCH] Hook UpdateUsable and OnUpdate --- ActionButton.lua | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/ActionButton.lua b/ActionButton.lua index 25c4ff1..919dd81 100644 --- a/ActionButton.lua +++ b/ActionButton.lua @@ -117,6 +117,7 @@ function Bartender4.Button:Create(id, parent) --self:UpdateAction(true) button:UpdateHotkeys() + button:UpdateUsable() return button end @@ -152,6 +153,16 @@ end local oor, oorcolor, oomcolor +local orig_ActionButton_OnUpdate = ActionButton_OnUpdate +ActionButton_OnUpdate = function(self, elapsed) + local name = self:GetName() + if self.BT4init then + onUpdate(self, elapsed) + else + orig_ActionButton_OnUpdate(self, elapsed) + end +end + function onUpdate(self, elapsed) if self.flashing == 1 then self.flashtime = self.flashtime - elapsed @@ -163,7 +174,7 @@ function onUpdate(self, elapsed) self.flashtime = ATTACK_BUTTON_FLASH_TIME - overtime local flashTexture = self.flash - if flashTexture:IsVisible() then + if flashTexture:IsShown() then flashTexture:Hide() else flashTexture:Show() @@ -251,7 +262,6 @@ function Button:UpdateAction(force) end local orig_ActionButton_UpdateHotkeys = ActionButton_UpdateHotkeys - ActionButton_UpdateHotkeys = function(self, ...) local name = self:GetName() if name and name:find("^BT4Button") then @@ -335,6 +345,18 @@ function Button:GetActionName() return format(actionTmpl, self.parent.id, self.rid) end +local orig_ActionButton_UpdateUsable = ActionButton_UpdateUsable +ActionButton_UpdateUsable = function(self, ...) + local name = self:GetName() + if name and name:find("^BT4Button") then + if self.BT4init then + self:UpdateUsable() + end + else + orig_ActionButton_UpdateUsable(self, ...) + end +end + function Button:UpdateUsable(force) local isUsable, notEnoughMana = IsUsableAction(self.action) local icon, hotkey = self.icon, self.hotkey