Mercurial > wow > reaction
changeset 131:e39d80bb0b7a
Refactored some code into Button, cleaned up PetActionButton a little
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Fri, 06 Mar 2009 23:58:02 +0000 |
parents | 6e4a11b9d290 |
children | 16048f516f5e |
files | classes/ActionButton.lua classes/Button.lua classes/PetActionButton.lua |
diffstat | 3 files changed, 34 insertions(+), 50 deletions(-) [+] |
line wrap: on
line diff
--- a/classes/ActionButton.lua Fri Mar 06 23:44:55 2009 +0000 +++ b/classes/ActionButton.lua Fri Mar 06 23:58:02 2009 +0000 @@ -168,20 +168,6 @@ local barFrame = bar:GetFrame() local config = self:GetConfig() - local frames = { } - self.frames = frames - frames.icon = _G[name.."Icon"] - frames.flash = _G[name.."Flash"] - frames.hotkey = _G[name.."HotKey"] - frames.count = _G[name.."Count"] - frames.name = _G[name.."Name"] - frames.border = _G[name.."Border"] - frames.cooldown = _G[name.."Cooldown"] - frames.normalTexture = _G[name.."NormalTexture"] - - self.hotkey = frames.hotkey -- alias for Button methods - self.border = frames.border -- alias for Button methods - self.rangeTimer = TOOLTIP_UPDATE_TIME -- set up the base action ID
--- a/classes/Button.lua Fri Mar 06 23:44:55 2009 +0000 +++ b/classes/Button.lua Fri Mar 06 23:58:02 2009 +0000 @@ -58,6 +58,17 @@ self.frame = f + local frames = { } + self.frames = frames + frames.icon = _G[name.."Icon"] + frames.flash = _G[name.."Flash"] + frames.hotkey = _G[name.."HotKey"] + frames.count = _G[name.."Count"] + frames.name = _G[name.."Name"] + frames.border = _G[name.."Border"] + frames.cooldown = _G[name.."Cooldown"] + frames.normalTexture = _G[name.."NormalTexture"] + if config then config.name = name end @@ -190,22 +201,22 @@ end function Button:UpdateKeybindModeDisplay( mode ) - self.border = self.border or _G[format("%sBorder",tostring(self:GetName()))] - if self.border then + local border = self.frames.border or _G[format("%sBorder",tostring(self:GetName()))] + if border then if mode then - self.border:SetVertexColor(KB:GetColorKeyBoundMode()) - self.border:Show() + border:SetVertexColor(KB:GetColorKeyBoundMode()) + border:Show() else - self.border:Hide() + border:Hide() end end end function Button:UpdateHotkey( hotkey ) - hotkey = hotkey or self.hotkey + hotkey = hotkey or self.frames.hotkey if not hotkey then hotkey = _G[self:GetName().."HotKey"] - self.hotkey = hotkey + self.frames.hotkey = hotkey end if hotkey then local txt = self.frame:GetHotkey()
--- a/classes/PetActionButton.lua Fri Mar 06 23:44:55 2009 +0000 +++ b/classes/PetActionButton.lua Fri Mar 06 23:58:02 2009 +0000 @@ -67,7 +67,7 @@ local f = self:GetFrame() if not f.autoCastTexture then - -- store with the frame for recycling + -- store autocast stuff with the frame for recycling f.autoCastShine = CreateFrame("Frame",name.."Shine",f,"AutoCastShineTemplate") local tex = f:CreateTexture(nil,"OVERLAY") tex:SetTexture([[Interface\Buttons\UI-AutoCastableOverlay]]) @@ -75,42 +75,29 @@ tex:SetWidth(58) tex:SetPoint("CENTER") f.autoCastTexture = tex + -- move the cooldown around + local cd = self.frames.cooldown + cd:ClearAllPoints() + cd:SetWidth(33) + cd:SetHeight(33) + cd:SetPoint("CENTER", f, "CENTER", -2, -1) + -- resize to 30x30 + f:SetHeight(30) + f:SetWidth(30) end local barFrame = bar:GetFrame() - local frames = { } - self.frames = frames - frames.icon = _G[name.."Icon"] - frames.flash = _G[name.."Flash"] - frames.hotkey = _G[name.."HotKey"] - frames.count = _G[name.."Count"] - frames.name = _G[name.."Name"] - frames.border = _G[name.."Border"] - frames.cooldown = _G[name.."Cooldown"] - frames.normalTexture = _G[name.."NormalTexture"] - - -- resize to 30x30 - f:SetHeight(30) - f:SetWidth(30) - - -- move the cooldown around - local cd = self.frames.cooldown - cd:ClearAllPoints() - cd:SetWidth(33) - cd:SetHeight(33) - cd:SetPoint("CENTER", f, "CENTER", -2, -1) - - self.hotkey = frames.hotkey -- alias for Button methods - self.border = frames.border -- alias for Button methods - -- set up the base action ID self:SetActionIDPool("pet",10) config.actionID = self:AcquireActionID(config.actionID, idHint, true) -- attribute setup - -- In order to get the full behavior of the pet buttons - -- (petattack, toggle autocast, start/stop attack) we need - -- to use a secure click proxy type instead of a "pet" type. + -- There's no secure way to do PetAutoCastToggle by actionID, so use + -- a click-through proxy to the Blizzard pet buttons for right-click + -- Note that technically this doesn't do PetStopAttack() when + -- IsPetAttackActive() is true: however that's only true when using + -- Eyes of the Beast and appears not to really do anything (at least + -- I can't find any difference) f:SetAttribute("type","pet") f:SetAttribute("type2","click") f:SetAttribute("clickbutton2",_G["PetActionButton"..config.actionID])