Mercurial > wow > reaction
diff modules/ReAction_PetAction/ReAction_PetAction.lua @ 102:ad49739d110d
Added feature to lock buttons (per-bar), with optional only-in-combat selector.
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Sun, 26 Oct 2008 02:26:31 +0000 |
parents | 168cae4aa8bd |
children | b2fb8f7dc780 |
line wrap: on
line diff
--- a/modules/ReAction_PetAction/ReAction_PetAction.lua Sat Oct 25 18:49:18 2008 +0000 +++ b/modules/ReAction_PetAction/ReAction_PetAction.lua Sun Oct 26 02:26:31 2008 +0000 @@ -25,6 +25,18 @@ -- Button class declaration local Button = { } +-- private +local function UpdateButtonLock(bar) + local f = bar:GetFrame() + f:SetAttribute("lockbuttons",bar.config.lockButtons) + f:SetAttribute("lockbuttonscombat",bar.config.lockButtonsCombat) + f:Execute( + [[ + lockButtons = self:GetAttribute("lockbuttons") + lockButtonsCombat = self:GetAttribute("lockbuttonscombat") + ]]) +end + -- module methods function module:OnInitialize() self.db = ReAction.db:RegisterNamespace( moduleID, @@ -116,6 +128,7 @@ end end end + UpdateButtonLock(bar) end end @@ -178,12 +191,69 @@ ---- Options ---- +local Handler = { } +local meta = { __index = Handler } + +function Handler:New(bar) + return setmetatable( + { + bar = bar, + config = bar.config + }, meta) +end + +function Handler:GetLockButtons() + return LOCK_ACTIONBAR == "1" or self.config.lockButtons +end + +function Handler:SetLockButtons(info, value) + self.config.lockButtons = value + UpdateButtonLock(self.bar) +end + +function Handler:LockButtonsDisabled() + return LOCK_ACTIONBAR == "1" +end + +function Handler:GetLockButtonsCombat() + return self.config.lockButtonsCombat +end + +function Handler:SetLockButtonsCombat(info, value) + self.config.lockButtonsCombat = value + UpdateButtonLock(self.bar) +end + +function Handler:LockButtonsCombatDisabled() + return LOCK_ACTIONBAR == "1" or not self.config.lockButtons +end + + function module:GetBarOptions(bar) if bar.config.type == moduleID then return { type = "group", name = L["Pet Buttons"], + handler = Handler:New(bar), args = { + lockButtons = { + name = L["Lock Buttons"], + desc = L["Prevents picking up/dragging actions.|nNOTE: This setting is overridden by the global setting in Blizzard's Action Buttons tab"], + order = 2, + type = "toggle", + disabled = "LockButtonsDisabled", + get = "GetLockButtons", + set = "SetLockButtons", + }, + lockOnlyCombat = { + name = L["Only in Combat"], + desc = L["Only lock the buttons when in combat"], + order = 3, + type = "toggle", + disabled = "LockButtonsCombatDisabled", + get = "GetLockButtonsCombat", + set = "SetLockButtonsCombat", + }, } } end @@ -414,6 +484,15 @@ end end) + -- install drag wrappers to lock buttons + bar:GetFrame():WrapScript(f, "OnDragStart", + -- OnDragStart(self, button, kind, value, ...) + [[ + if lockButtons and (PlayerInCombat() or not lockButtonsCombat) and not IsModifiedClick("PICKUPACTION") then + return "clear" + end + ]]) + KBAttach(self) self:Refresh()