diff --git a/ActionBar.lua b/ActionBar.lua index 4a21bae..d4bdaa0 100644 --- a/ActionBar.lua +++ b/ActionBar.lua @@ -73,11 +73,6 @@ function ActionBar:SkinChanged(...) self:ForAll("Update") end -function ActionBar:SetShow(...) - ButtonBar.SetShow(self, ...) - self:UpdateStates() -end - --[[=================================================================================== ActionBar Config Interface diff --git a/ActionBarStates.lua b/ActionBarStates.lua index 58b7ad5..e0f0a79 100644 --- a/ActionBarStates.lua +++ b/ActionBarStates.lua @@ -54,7 +54,6 @@ local searchFunc = function(h, n) return (h.match == n or h.match2 == n or h.id local stancemap function ActionBar:UpdateStates() if not self.buttons then return end - self:InitVisibilityDriver() self.statebutton = {} if not stancemap and DefaultStanceMap[playerclass] then stancemap = DefaultStanceMap[playerclass] @@ -79,11 +78,7 @@ function ActionBar:UpdateStates() for _,v in pairs(modifiers) do local page = self:GetStateOption(v) if page and page ~= 0 then - if page == -1 then - self:RegisterVisibilityCondition(fmt("[modifier:%s]hide", v)) - else - table_insert(statedriver, fmt("[modifier:%s]%s", v, page)) - end + table_insert(statedriver, fmt("[modifier:%s]%s", v, page)) end end @@ -103,18 +98,10 @@ function ActionBar:UpdateStates() if playerclass == "DRUID" and v.id == "cat" then local prowl = self:GetStanceState("prowl") if prowl then - if prowl == -1 then - self:RegisterVisibilityCondition(fmt("[bonusbar:%s,stealth:1]hide", v.index)) - else - table_insert(statedriver, fmt("[bonusbar:%s,stealth:1]%s", v.index, prowl)) - end + table_insert(statedriver, fmt("[bonusbar:%s,stealth:1]%s", v.index, prowl)) end end - if state == -1 then - self:RegisterVisibilityCondition(fmt("[bonusbar:%s]hide", v.index)) - else - table_insert(statedriver, fmt("[bonusbar:%s]%s", v.index, state)) - end + table_insert(statedriver, fmt("[bonusbar:%s]%s", v.index, state)) end end end @@ -130,8 +117,6 @@ function ActionBar:UpdateStates() --local newState = self:GetAttribute("state-page") --self:SetAttribute("state", newState) - - self:ApplyVisibilityDriver() end function ActionBar:GetStanceState(stance) diff --git a/ActionBars.lua b/ActionBars.lua index 3c625db..b206550 100644 --- a/ActionBars.lua +++ b/ActionBars.lua @@ -37,6 +37,9 @@ local abdefaults = { ROGUE = { stealth = 7 } }, }, + visibility = { + possess = false, + }, }, [7] = { enabled = false, diff --git a/BagBar.lua b/BagBar.lua index b34f49d..3f955d3 100644 --- a/BagBar.lua +++ b/BagBar.lua @@ -16,6 +16,9 @@ local defaults = { profile = Bartender4:Merge({ enabled = true, keyring = false, onebag = false, + visibility = { + possess = false, + }, }, Bartender4.ButtonBar.defaults) } function BagBarMod:OnInitialize() diff --git a/Bar.lua b/Bar.lua index 5c5d467..e79f6f6 100644 --- a/Bar.lua +++ b/Bar.lua @@ -18,7 +18,9 @@ local defaults = { fadeout = false, fadeoutalpha = 0.1, fadeoutdelay = 0.2, - show = "alwaysshow", + visibility = { + possess = true, + }, } local barOnEnter, barOnLeave, barOnDragStart, barOnDragStop, barOnClick, barOnUpdateFunc @@ -138,7 +140,6 @@ function Bar:ApplyConfig(config) end if self.disabled then return end self:InitVisibilityDriver() - self:SetShow() self:Lock() self:LoadPosition() self:SetConfigScale() @@ -201,28 +202,6 @@ function Bar:SetSize(width, height) self:SetHeight(height or width) end -function Bar:GetShow() - return self.config.show -end - -function Bar:SetShow(show) - if show ~= nil then - self.config.show = show - end - if not self.unlocked then - self:InitVisibilityDriver() - self:ApplyVisibilityDriver() - else - self:Show() - self:InitVisibilityDriver() - if self.config.show == "alwayshide" then - self.overlay:SetBackdropColor(1, 0, 0, 0.5) - else - self.overlay:SetBackdropColor(0, 1, 0, 0.5) - end - end -end - function Bar:GetConfigAlpha() return self.config.alpha end @@ -301,29 +280,37 @@ function Bar:ControlFadeOut() end end - +local directVisCond = { + pet = true, + nopet = true, + combat = true, + nocomat = true, + mounted = true, +} function Bar:InitVisibilityDriver() self.hidedriver = {} UnregisterStateDriver(self, 'visibility') - if self.config.show == "alwaysshow" or self.config.show == true then - -- - elseif self.config.show == "alwayshide" or self.config.show == false then - self:RegisterVisibilityCondition("hide") - elseif self.config.show == "combatshow" then - self:RegisterVisibilityCondition("[nocombat]hide") - elseif self.config.show == "combathide" then - self:RegisterVisibilityCondition("[combat]hide") + + for key, value in pairs(self.config.visibility) do + if value then + if key == "always" then + table_insert(self.hidedriver, "hide") + elseif key == "possess" then + table_insert(self.hidedriver, "[bonusbar:5]hide") + elseif directVisCond[key] then + table_insert(self.hidedriver, ("[%s]hide"):format(key)) + else + Bartender4:Print("Invalid visibility state: "..key) + end + end end -end - -function Bar:RegisterVisibilityCondition(condition) - table_insert(self.hidedriver, condition) + table_insert(self.hidedriver, "show") end function Bar:ApplyVisibilityDriver() if self.unlocked then return end -- default state is shown - RegisterStateDriver(self, "visibility", table_concat(self.hidedriver, ";") .. ";show") + RegisterStateDriver(self, "visibility", table_concat(self.hidedriver, ";")) end function Bar:DisableVisibilityDriver() diff --git a/MicroMenu.lua b/MicroMenu.lua index aa44014..5376db4 100644 --- a/MicroMenu.lua +++ b/MicroMenu.lua @@ -15,6 +15,9 @@ local table_insert = table.insert local defaults = { profile = Bartender4:Merge({ enabled = true, vertical = false, + visibility = { + possess = false, + }, }, Bartender4.Bar.defaults) } function MicroMenuMod:OnInitialize() diff --git a/Options/ActionBarStates.lua b/Options/ActionBarStates.lua index 6d2626f..462b681 100644 --- a/Options/ActionBarStates.lua +++ b/Options/ActionBarStates.lua @@ -50,7 +50,6 @@ end local hasStances local validStanceTable = { - [-1] = "Hide", [0] = "Don't Page", ("Page %2d"):format(1), ("Page %2d"):format(2), diff --git a/Options/Bar.lua b/Options/Bar.lua index a92bab7..dd55157 100644 --- a/Options/Bar.lua +++ b/Options/Bar.lua @@ -16,7 +16,6 @@ do optionMap = { alpha = "ConfigAlpha", scale = "ConfigScale", - show = "Show", fadeout = "FadeOut", fadeoutalpha = "FadeOutAlpha", fadeoutdelay = "FadeOutDelay", @@ -51,8 +50,6 @@ do end end -local showOptions = { alwaysshow = L["Always Show"], alwayshide = L["Always Hide"], combatshow = L["Show in Combat"], combathide = L["Hide in Combat"] } - local options function Bar:GetOptionObject() local otbl = { @@ -62,15 +59,6 @@ function Bar:GetOptionObject() name = L["General Settings"], order = 1, args = { - show = { - order = 5, - type = "select", - name = L["Show/Hide"], - desc = L["Configure when to Show/Hide the bar."], - get = optGetter, - set = optSetter, - values = showOptions, - }, styleheader = { order = 10, type = "header", diff --git a/PetBar.lua b/PetBar.lua index adc9737..527538f 100644 --- a/PetBar.lua +++ b/PetBar.lua @@ -13,6 +13,9 @@ local PetBar = setmetatable({}, {__index = ButtonBar}) local defaults = { profile = Bartender4:Merge({ enabled = true, scale = 1.0, + visibility = { + nopet = true, + }, }, Bartender4.ButtonBar.defaults) } function PetBarMod:OnInitialize() @@ -108,11 +111,6 @@ end function PetBar:ApplyConfig(config) ButtonBar.ApplyConfig(self, config) self:UpdateButtonLayout() - self:InitVisibilityDriver() - self:RegisterVisibilityCondition("[bonusbar:5]hide") - self:RegisterVisibilityCondition("[pet]show") - self:RegisterVisibilityCondition("hide") - self:ApplyVisibilityDriver() self:ForAll("Update") self:ForAll("ApplyStyle", self.config.style) end diff --git a/TODO.txt b/TODO.txt index 5d7267d..bbe5824 100644 --- a/TODO.txt +++ b/TODO.txt @@ -3,5 +3,4 @@ Bartender4 TODO List - Option to change self-cast modifier assignment (Blizzard kinda removed that <.<) - Alignment Menu - Options to control the removal of the Blizzard Artwork Bottom Bar -- Add Skin Configuration Options (ButtonFacade) into the BT4 config -- Localization \ No newline at end of file +- Improved Show/Hide functionality \ No newline at end of file