- now using LibKeyBound-1.0
- added more options to configure the show/hide state of the bar, now supports showing/hiding bars based on in-combat
This commit is contained in:
+1
-1
@@ -191,7 +191,7 @@ end
|
||||
-- Creates a new bar object based on the id and the specified config
|
||||
function BT4ActionBars:Create(id, config)
|
||||
local id = tostring(id)
|
||||
local bar = setmetatable(Bartender4.ButtonBar:Create(id, "SecureStateHeaderTemplate", config), ActionBar_MT)
|
||||
local bar = setmetatable(Bartender4.ButtonBar:Create(id, config), ActionBar_MT)
|
||||
bar.module = self
|
||||
|
||||
self:CreateBarOption(id)
|
||||
|
||||
@@ -14,7 +14,7 @@ local Bar_MT = {__index = Bar}
|
||||
local defaults = {
|
||||
scale = 1,
|
||||
alpha = 1,
|
||||
show = true
|
||||
show = "alwaysshow",
|
||||
}
|
||||
|
||||
local barOnEnter, barOnLeave, barOnDragStart, barOnDragStop, barOnClick
|
||||
@@ -53,11 +53,11 @@ Bartender4.Bar = {}
|
||||
Bartender4.Bar.defaults = defaults
|
||||
Bartender4.Bar.prototype = Bar
|
||||
Bartender4.Bar.barregistry = barregistry
|
||||
function Bartender4.Bar:Create(id, template, config)
|
||||
function Bartender4.Bar:Create(id, config)
|
||||
id = tostring(id)
|
||||
assert(not barregistry[id], "duplicated entry in barregistry.")
|
||||
|
||||
local bar = setmetatable(CreateFrame("Frame", ("BT4Bar%s"):format(id), UIParent, template), Bar_MT)
|
||||
local bar = setmetatable(CreateFrame("Frame", ("BT4Bar%s"):format(id), UIParent, "SecureStateHeaderTemplate"), Bar_MT)
|
||||
barregistry[id] = bar
|
||||
bar.id = id
|
||||
bar:SetMovable(true)
|
||||
@@ -157,6 +157,8 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
local showOptions = { alwaysshow = "Always Show", alwayshide = "Always Hide", combatshow = "Show in Combat", combathide = "Hide in Combat" }
|
||||
|
||||
local options
|
||||
function Bar:GetOptionObject()
|
||||
local otbl = {
|
||||
@@ -168,11 +170,12 @@ function Bar:GetOptionObject()
|
||||
args = {
|
||||
show = {
|
||||
order = 5,
|
||||
type = "toggle",
|
||||
name = "Show",
|
||||
desc = "Show/Hide the bar.",
|
||||
type = "select",
|
||||
name = "Show/Hide",
|
||||
desc = "Configure when to Show/Hide the bar.",
|
||||
get = optGetter,
|
||||
set = optSetter,
|
||||
values = showOptions,
|
||||
},
|
||||
styleheader = {
|
||||
order = 10,
|
||||
@@ -235,9 +238,10 @@ end
|
||||
function Bar:Unlock()
|
||||
if self.disabled or self.unlocked then return end
|
||||
self.unlocked = true
|
||||
UnregisterStateDriver(self, "visibility")
|
||||
self:Show()
|
||||
self.overlay:Show()
|
||||
if not self.config.show then
|
||||
if self.config.show == "alwayshide" then
|
||||
self.overlay:SetBackdropColor(1, 0, 0, 0.5)
|
||||
else
|
||||
self.overlay:SetBackdropColor(0, 1, 0, 0.5)
|
||||
@@ -249,9 +253,7 @@ function Bar:Lock()
|
||||
self.unlocked = nil
|
||||
barOnDragStop(self.overlay)
|
||||
|
||||
if not self.config.show then
|
||||
self:Hide()
|
||||
end
|
||||
self:ConfigureShowStates()
|
||||
|
||||
self.overlay:Hide()
|
||||
end
|
||||
@@ -289,10 +291,10 @@ function Bar:SetShow(show)
|
||||
self.config.show = show
|
||||
end
|
||||
if not self.unlocked then
|
||||
self[self.config.show and "Show" or "Hide"](self)
|
||||
self:ConfigureShowStates()
|
||||
else
|
||||
self:Show()
|
||||
if not self.config.show then
|
||||
if self.config.show == "alwayshide" then
|
||||
self.overlay:SetBackdropColor(1, 0, 0, 0.5)
|
||||
else
|
||||
self.overlay:SetBackdropColor(0, 1, 0, 0.5)
|
||||
@@ -300,6 +302,20 @@ function Bar:SetShow(show)
|
||||
end
|
||||
end
|
||||
|
||||
function Bar:ConfigureShowStates()
|
||||
UnregisterStateDriver(self, 'visibility')
|
||||
local conditions
|
||||
if self.config.show == "alwaysshow" or self.config.show == true then
|
||||
self:Show()
|
||||
elseif self.config.show == "alwayshide" or self.config.show == false then
|
||||
self:Hide()
|
||||
elseif self.config.show == "combatshow" then
|
||||
RegisterStateDriver(self, 'visibility', '[combat]show;hide')
|
||||
elseif self.config.show == "combathide" then
|
||||
RegisterStateDriver(self, 'visibility', '[combat]hide;show')
|
||||
end
|
||||
end
|
||||
|
||||
function Bar:GetConfigAlpha()
|
||||
return self.config.alpha
|
||||
end
|
||||
|
||||
+2
-3
@@ -3,13 +3,12 @@
|
||||
## Title: Bartender4
|
||||
## Author: Nevcairiel
|
||||
## SavedVariables: Bartender4DB
|
||||
## OptionalDeps: Ace3, ButtonFacade
|
||||
## X-Embeds: Ace3
|
||||
## OptionalDeps: Ace3, ButtonFacade, LibKeyBound-1.0
|
||||
## X-Embeds: Ace3, LibKeyBound-1.0
|
||||
## X-Category: Action Bars
|
||||
## Version: 4.0
|
||||
|
||||
embeds.xml
|
||||
keyBound\keyBound.xml
|
||||
|
||||
locale\locale.xml
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ local IsUsableAction = IsUsableAction
|
||||
local IsActionInRange = IsActionInRange
|
||||
|
||||
local LBF = LibStub("LibButtonFacade", true)
|
||||
local KeyBound = LibStub("LibKeyBound-1.0")
|
||||
|
||||
Bartender4.Button = {}
|
||||
Bartender4.Button.prototype = Button
|
||||
|
||||
+2
-2
@@ -23,8 +23,8 @@ Bartender4.ButtonBar.defaults = defaults
|
||||
|
||||
local LBF = LibStub("LibButtonFacade", true)
|
||||
|
||||
function Bartender4.ButtonBar:Create(id, template, config)
|
||||
local bar = setmetatable(Bartender4.Bar:Create(id, template, config), ButtonBar_MT)
|
||||
function Bartender4.ButtonBar:Create(id, config)
|
||||
local bar = setmetatable(Bartender4.Bar:Create(id, config), ButtonBar_MT)
|
||||
|
||||
if LBF then
|
||||
bar.LBFGroup = LBF:Group("Bartender4", tostring(id))
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ local noopFunc = function() end
|
||||
|
||||
function MicroMenuMod:OnEnable()
|
||||
if not self.bar then
|
||||
self.bar = setmetatable(Bartender4.Bar:Create("MicroMenu", nil, self.db.profile), {__index = MicroMenuBar})
|
||||
self.bar = setmetatable(Bartender4.Bar:Create("MicroMenu", self.db.profile), {__index = MicroMenuBar})
|
||||
local buttons = {}
|
||||
table_insert(buttons, CharacterMicroButton)
|
||||
table_insert(buttons, SpellbookMicroButton)
|
||||
|
||||
+2
-1
@@ -13,6 +13,7 @@ local PetButtonPrototype = CreateFrame("CheckButton")
|
||||
local PetButton_MT = {__index = PetButtonPrototype}
|
||||
|
||||
local LBF = LibStub("LibButtonFacade", true)
|
||||
local KeyBound = LibStub("LibKeyBound-1.0")
|
||||
|
||||
local defaults = { profile = Bartender4:Merge({
|
||||
enabled = true,
|
||||
@@ -26,7 +27,7 @@ end
|
||||
|
||||
function PetBarMod:OnEnable()
|
||||
if not self.bar then
|
||||
self.bar = setmetatable(Bartender4.ButtonBar:Create("Pet", nil, self.db.profile), {__index = PetBar})
|
||||
self.bar = setmetatable(Bartender4.ButtonBar:Create("Pet", self.db.profile), {__index = PetBar})
|
||||
|
||||
local buttons = {}
|
||||
for i=1,10 do
|
||||
|
||||
+2
-1
@@ -15,6 +15,7 @@ local StanceButton_MT = {__index = StanceButtonPrototype}
|
||||
local format = string.format
|
||||
|
||||
local LBF = LibStub("LibButtonFacade", true)
|
||||
local KeyBound = LibStub("LibKeyBound-1.0")
|
||||
|
||||
local defaults = { profile = Bartender4:Merge({
|
||||
enabled = true,
|
||||
@@ -28,7 +29,7 @@ end
|
||||
|
||||
function StanceBarMod:OnEnable()
|
||||
if not self.bar then
|
||||
self.bar = setmetatable(Bartender4.ButtonBar:Create("Stance", nil, self.db.profile), {__index = StanceBar})
|
||||
self.bar = setmetatable(Bartender4.ButtonBar:Create("Stance", self.db.profile), {__index = StanceBar})
|
||||
|
||||
self.bar:ClearSetPoint("CENTER")
|
||||
self.bar:SetScript("OnEvent", StanceBar.OnEvent)
|
||||
|
||||
@@ -10,4 +10,5 @@
|
||||
<Include file="libs\AceLocale-3.0\AceLocale-3.0.xml"/>
|
||||
<Include file="libs\AceGUI-3.0\AceGUI-3.0.xml"/>
|
||||
<Include file="libs\AceConfig-3.0\AceConfig-3.0.xml"/>
|
||||
<Include file="libs\LibKeyBound-1.0\lib.xml"/>
|
||||
</Ui>
|
||||
|
||||
Reference in New Issue
Block a user