From 37520f8b58ac8ed14c2c1d1829a0c398994780ec Mon Sep 17 00:00:00 2001 From: Hendrik Leppkes Date: Tue, 11 Dec 2007 13:02:06 +0000 Subject: [PATCH] more work done and fixes applied --- ActionBars.lua | 10 +++++++--- Bar.lua | 36 +++++++++++++++++++++++++++++++++--- Bartender4.lua | 30 ++++++++++++++++++++++++++++++ Button.lua | 14 ++++++++------ Options.lua | 7 +++++++ 5 files changed, 85 insertions(+), 12 deletions(-) diff --git a/ActionBars.lua b/ActionBars.lua index 6999ca1..eaa7ee5 100644 --- a/ActionBars.lua +++ b/ActionBars.lua @@ -12,6 +12,7 @@ local stancedefaults = { local defaults = Bartender4:Merge({ ['**'] = { + Enabled = true, Buttons = 12, Padding = 2, Rows = 1, @@ -192,8 +193,6 @@ function BT4ActionBars:Create(id, config) self:CreateBarOption(id, self:GetOptionsTable()) bar:ApplyConfig() - -- debugging - --bar:Unlock() return bar end @@ -204,6 +203,7 @@ function BT4ActionBars:DisableBar(id) if not bar then return end bar.config.Enabled = false + bar.disabled = true bar:Hide() self:CreateBarOption(id, self.disabledoptions) end @@ -217,7 +217,11 @@ function BT4ActionBars:EnableBar(id) bar = self:Create(id, config) self.actionbars[id] = bar else + bar.disabled = nil self:CreateBarOption(id, self:GetOptionsTable()) + bar:ApplyConfig(config) + end + if not Bartender4.Locked then + bar:Unlock() end - bar:ApplyConfig(config) end diff --git a/Bar.lua b/Bar.lua index 532b423..03e42bd 100644 --- a/Bar.lua +++ b/Bar.lua @@ -13,7 +13,6 @@ local Bar_MT = {__index = Bar} local defaults = { ['**'] = { - Enabled = true, Scale = 1, Alpha = 1, Show = true, @@ -59,6 +58,19 @@ function Bartender4.Bar:Create(id, template, config) return bar end +function Bartender4.Bar:GetAll() + return pairs(barregistry) +end + +function Bartender4.Bar:ForAll(method, ...) + for _,bar in self:GetAll() do + local func = bar[method] + if func then + func(bar, ...) + end + end +end + --[[=================================================================================== Bar Options ===================================================================================]]-- @@ -198,6 +210,7 @@ function Bar:ApplyConfig(config) if config then self.config = config end + if self.disabled then return end self:SetShow() self:Lock() self:LoadPosition() @@ -206,6 +219,8 @@ function Bar:ApplyConfig(config) end function Bar:Unlock() + if self.disabled or self.unlocked then return end + self.unlocked = true self:EnableMouse(true) self:SetScript("OnEnter", barOnEnter) self:SetScript("OnLeave", barOnLeave) @@ -214,8 +229,9 @@ function Bar:Unlock() self:SetScript("OnClick", barOnClick) self.Text:Show() + self:Show() self:SetFrameLevel(5) - if self.config.Hide then + if not self.config.Show then self:SetBackdropColor(1, 0, 0, 0.5) else self:SetBackdropColor(0, 1, 0, 0.5) @@ -223,6 +239,8 @@ function Bar:Unlock() end function Bar:Lock() + if self.disabled or not self.unlocked then return end + self.unlocked = nil barOnDragStop(self) self:EnableMouse(false) self:SetScript("OnEnter", nil) @@ -232,6 +250,10 @@ function Bar:Lock() self:SetScript("OnClick", nil) self.Text:Hide() + if not self.config.Show then + self:Hide() + end + self:SetBackdropColor(0, 0, 0, 0) self:SetBackdropBorderColor(0, 0, 0, 0) end @@ -268,7 +290,15 @@ function Bar:SetShow(show) if show ~= nil then self.config.Show = show end - self[self.config.Show and "Show" or "Hide"](self) + if not self.unlocked then + self[self.config.Show and "Show" or "Hide"](self) + else + if not self.config.Show then + self:SetBackdropColor(1, 0, 0, 0.5) + else + self:SetBackdropColor(0, 1, 0, 0.5) + end + end end function Bar:GetConfigAlpha() diff --git a/Bartender4.lua b/Bartender4.lua index be64586..adcc867 100644 --- a/Bartender4.lua +++ b/Bartender4.lua @@ -16,6 +16,9 @@ function Bartender4:OnInitialize() self.db.RegisterCallback(self, "OnProfileReset", "UpdateModuleConfigs") self:SetupOptions() + + self.Locked = true + self:RegisterEvent("PLAYER_REGEN_DISABLED", "CombatLockdown") end function Bartender4:RegisterDefaultsKey(key, subdefaults) @@ -25,6 +28,7 @@ function Bartender4:RegisterDefaultsKey(key, subdefaults) end function Bartender4:UpdateModuleConfigs() + self:Lock() for k,v in AceAddon:IterateModulesOfAddon("Bartender4") do if type(v.ApplyConfig) == "function" then v:ApplyConfig() @@ -40,6 +44,32 @@ function Bartender4:Update() end end +function Bartender4:CombatLockdown() + self:Lock() +end + +function Bartender4:ToggleLock() + if self.Locked then + self:Unlock() + else + self:Lock() + end +end + +function Bartender4:Unlock() + if self.Locked then + self.Locked = false + Bartender4.Bar:ForAll("Unlock") + end +end + +function Bartender4:Lock() + if not self.Locked then + self.Locked = true + Bartender4.Bar:ForAll("Lock") + end +end + function Bartender4:Merge(target, source) if not target then target = {} end for k,v in pairs(source) do diff --git a/Button.lua b/Button.lua index 0588c80..6dc6734 100644 --- a/Button.lua +++ b/Button.lua @@ -34,13 +34,15 @@ function Bartender4.Button:Create(id, parent) button.flash = _G[("%sFlash"):format(name)] button.flash:Hide() - button:SetNormalTexture("") - local realNormalTexture = _G[("%sNormalTexture"):format(name)] - realNormalTexture:Hide() + --button:SetNormalTexture("") + --local realNormalTexture = _G[("%sNormalTexture"):format(name)] - button.normalTexture = button:CreateTexture(("%sBT4NormalTexture"):format(name)) - button.normalTexture:SetAllPoints(realNormalTexture) + --button.normalTexture = button:CreateTexture(("%sBT4NormalTexture"):format(name)) + --button.normalTexture:SetAllPoints(realNormalTexture) + --realNormalTexture:Hide() + + button.normalTexture = button:GetNormalTexture() -- _G[("%sNormalTexture"):format(name)] button.pushedTexture = button:GetPushedTexture() button.highlightTexture = button:GetHighlightTexture() @@ -66,7 +68,7 @@ function Bartender4.Button:Create(id, parent) button:RegisterButtonEvents() button:Show() - button:UpdateAction() + button:UpdateAction(true) return button end diff --git a/Options.lua b/Options.lua index 8c6348a..c595255 100644 --- a/Options.lua +++ b/Options.lua @@ -37,6 +37,13 @@ function Bartender4:SetupOptions() set = setFunc, args = {}, }, + lock = { + dialogHidden = true, + type = "toggle", + name = "Lock/Unlock the bars.", + get = function() return Bartender4.Locked end, + set = function(info, value) Bartender4:ToggleLock(value) end, + }, }, } LibStub("AceConfig-3.0"):RegisterOptionsTable("Bartender4", self.options, {"bar", "bt", "bt4"})