# HG changeset patch # User Flick # Date 1224987991 0 # Node ID ad49739d110d41eea8b257bab073dfda1026f905 # Parent 3699d7dad312a6e98e3e53f79373405da9219db9 Added feature to lock buttons (per-bar), with optional only-in-combat selector. diff -r 3699d7dad312 -r ad49739d110d locale/enUS.lua --- a/locale/enUS.lua Sat Oct 25 18:49:18 2008 +0000 +++ b/locale/enUS.lua Sun Oct 26 02:26:31 2008 +0000 @@ -118,6 +118,10 @@ "Action Bar", "Action Bars", "Hide Empty Buttons", +"Lock Buttons", +"Prevents picking up/dragging actions.|nNOTE: This setting is overridden by the global setting in Blizzard's Action Buttons tab", +"Only in Combat", +"Only lock the buttons when in combat", "# Pages", "Use the Dynamic State tab to specify page transitions", "Edit Action IDs", diff -r 3699d7dad312 -r ad49739d110d modules/ReAction_Action/ReAction_Action.lua --- a/modules/ReAction_Action/ReAction_Action.lua Sat Oct 25 18:49:18 2008 +0000 +++ b/modules/ReAction_Action/ReAction_Action.lua Sun Oct 26 02:26:31 2008 +0000 @@ -150,10 +150,28 @@ get = "GetHideEmpty", set = "SetHideEmpty", }, + 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", + }, pages = { name = L["# Pages"], desc = L["Use the Dynamic State tab to specify page transitions"], - order = 2, + order = 4, type = "range", min = 1, max = 10, @@ -164,7 +182,7 @@ mindcontrol = { name = L["Mind Control Support"], desc = L["When possessing a target (e.g. via Mind Control), map the first 12 buttons of this bar to the possessed target's actions."], - order = 3, + order = 5, type = "toggle", width = "double", set = "SetMindControl", @@ -172,7 +190,7 @@ }, actions = { name = L["Edit Action IDs"], - order = 4, + order = 6, type = "group", inline = true, args = { @@ -290,10 +308,10 @@ end end end + local f = self.bar:GetFrame() for _, b in ipairs(self.btns) do b:Refresh() end - local f = self.bar:GetFrame() f:SetAttribute("mindcontrol",self.config.mindcontrol) f:Execute( [[ @@ -307,6 +325,7 @@ control:ChildUpdate() ]]) RegisterStateDriver(f, "mindcontrol", "[bonusbar:5] mc; none") + self:UpdateButtonLock() end function Handle:Destroy() @@ -330,6 +349,17 @@ end end + function Handle:UpdateButtonLock() + local f = self.bar:GetFrame() + f:SetAttribute("lockbuttons",self.config.lockButtons) + f:SetAttribute("lockbuttonscombat",self.config.lockButtonsCombat) + f:Execute( + [[ + lockButtons = self:GetAttribute("lockbuttons") + lockButtonsCombat = self:GetAttribute("lockbuttonscombat") + ]]) + end + function Handle:SetKeybindMode(mode) for _, b in pairs(self.btns) do if mode then @@ -360,10 +390,8 @@ function Handle:SetHideEmpty(info, value) if value ~= self.config.hideEmpty then - for b in self.bar:IterateButtons() do - b:ShowGrid(not value) - end self.config.hideEmpty = value + self:ShowGrid(not value) end end @@ -371,6 +399,32 @@ return self.config.hideEmpty end + function Handle:GetLockButtons() + return LOCK_ACTIONBAR == "1" or self.config.lockButtons + end + + function Handle:SetLockButtons(info, value) + self.config.lockButtons = value + self:UpdateButtonLock() + end + + function Handle:LockButtonsDisabled() + return LOCK_ACTIONBAR == "1" + end + + function Handle:GetLockButtonsCombat() + return self.config.lockButtonsCombat + end + + function Handle:SetLockButtonsCombat(info, value) + self.config.lockButtonsCombat = value + self:UpdateButtonLock() + end + + function Handle:LockButtonsCombatDisabled() + return LOCK_ACTIONBAR == "1" or not self.config.lockButtons + end + function Handle:GetNumPages() return self.config.nPages end @@ -898,6 +952,15 @@ self:SetAttribute("action",value) ]]) + -- 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 + ]]) + self.frame = f self.normalTexture = getglobal(format("%sNormalTexture",f:GetName())) diff -r 3699d7dad312 -r ad49739d110d modules/ReAction_PetAction/ReAction_PetAction.lua --- 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()