From bc390827952b339980387af3296ce97f5cd32aa0 Mon Sep 17 00:00:00 2001 From: Hendrik Leppkes Date: Thu, 21 May 2009 12:51:34 +0200 Subject: [PATCH] Further optimizations to the range check. --- ActionBar.lua | 3 ++- ActionButton.lua | 53 +++++++++++++++++++++++++++++++----------------- 2 files changed, 36 insertions(+), 20 deletions(-) diff --git a/ActionBar.lua b/ActionBar.lua index a3c6ed3..60cea21 100644 --- a/ActionBar.lua +++ b/ActionBar.lua @@ -25,6 +25,7 @@ function ActionBar:ApplyConfig(config) if not self.config.position.x then initialPosition(self) end + Bartender4.Button:UpdateRangeValues() self:UpdateButtons() end @@ -49,7 +50,7 @@ function ActionBar:UpdateButtons(numbuttons) buttons[i]:SetParent(self) buttons[i]:Show() buttons[i]:SetAttribute("statehidden", nil) - buttons[i]:UpdateAction(true) + buttons[i]:Update() end -- hide inactive buttons diff --git a/ActionButton.lua b/ActionButton.lua index 6f819df..1afa1a1 100644 --- a/ActionButton.lua +++ b/ActionButton.lua @@ -29,6 +29,8 @@ local Bartender4 = Bartender4 local LBF = LibStub("LibButtonFacade", true) local KeyBound = LibStub("LibKeyBound-1.0") +local oorsetting, oorcolor, oomcolor + Bartender4.Button = {} Bartender4.Button.prototype = Button Button.BT4init = true @@ -191,6 +193,11 @@ function Bartender4.Button:Create(id, parent) return button end +function Bartender4.Button:UpdateRangeValues() + oorsetting = Bartender4.db.profile.outofrange + oorcolor, oomcolor = Bartender4.db.profile.colors.range, Bartender4.db.profile.colors.mana +end + function onDragUpdate(self) ActionButton_UpdateState(self) ActionButton_UpdateFlash(self) @@ -226,15 +233,25 @@ function onUpdate(self, elapsed) self.rangeTimer = self.rangeTimer - elapsed if self.rangeTimer <= 0 then local valid = IsActionInRange(self.action) - local hotkey = self.hotkey - local hkshown = (hotkey:GetText() == RANGE_INDICATOR and Bartender4.db.profile.outofrange == "hotkey") - if valid and hkshown then - hotkey:Show() - elseif hkshown then - hotkey:Hide() - end self.outOfRange = (valid == 0) - self:UpdateUsable() + + if oorsetting == "hotkey" then + local hotkey = self.hotkey + local hkshown = hotkey:GetText() == RANGE_INDICATOR + if valid and hkshown then + hotkey:Show() + elseif hkshown then + hotkey:Hide() + end + + if self.outOfRange then + hotkey:SetVertexColor(oorcolor.r, oorcolor.g, oorcolor.b) + else + hotkey:SetVertexColor(1.0, 1.0, 1.0) + end + elseif oorsetting == "button" then + self:UpdateUsable() + end self.rangeTimer = TOOLTIP_UPDATE_TIME end end @@ -328,6 +345,7 @@ function Button:Update() self:UpdateAction(true) self:UpdateHotkeys() self:ToggleButtonElements() + self:UpdateRange() end function Button:UpdateAction(force) @@ -434,20 +452,11 @@ end) function Button:UpdateUsable() local isUsable, notEnoughMana = IsUsableAction(self.action) - local icon, hotkey = self.icon, self.hotkey - local oor = Bartender4.db.profile.outofrange - local oorcolor, oomcolor = Bartender4.db.profile.colors.range, Bartender4.db.profile.colors.mana + local icon = self.icon - if oor == "button" and self.outOfRange then + if oorsetting == "button" and self.outOfRange then icon:SetVertexColor(oorcolor.r, oorcolor.g, oorcolor.b) - hotkey:SetVertexColor(1.0, 1.0, 1.0) else - if oor == "hotkey" and self.outOfRange then - hotkey:SetVertexColor(oorcolor.r, oorcolor.g, oorcolor.b) - else - hotkey:SetVertexColor(1.0, 1.0, 1.0) - end - if isUsable or specialButtons[self.action] then icon:SetVertexColor(1.0, 1.0, 1.0) elseif notEnoughMana then @@ -458,6 +467,12 @@ function Button:UpdateUsable() end end +function Button:UpdateRange() + self.hotkey:SetVertexColor(1.0, 1.0, 1.0) + self:UpdateUsable() + onUpdate(self, 10) +end + function Button:SetTooltip() if ( GetCVar("UberTooltips") == "1" ) then GameTooltip_SetDefaultAnchor(GameTooltip, self)