more options tweaks

This commit is contained in:
Hendrik Leppkes
2008-04-08 11:08:59 +00:00
parent b6adf401f6
commit e4510fbbb4
+16 -4
View File
@@ -67,6 +67,7 @@ function BT4ActionBars:OnEnable()
if first then if first then
self.playerclass = select(2, UnitClass("player")) self.playerclass = select(2, UnitClass("player"))
self.actionbars = {} self.actionbars = {}
for i=1,10 do for i=1,10 do
local config = self.db.profile.actionbars[i] local config = self.db.profile.actionbars[i]
if config.enabled then if config.enabled then
@@ -75,16 +76,20 @@ function BT4ActionBars:OnEnable()
self:CreateBarOption(i, self.disabledoptions) self:CreateBarOption(i, self.disabledoptions)
end end
end end
first = nil first = nil
end end
self:RegisterEvent("UPDATE_BINDINGS", "ReassignBindings") self:RegisterEvent("UPDATE_BINDINGS", "ReassignBindings")
self:ReassignBindings() self:ReassignBindings()
end end
function BT4ActionBars:SetupOptions() function BT4ActionBars:SetupOptions()
if not self.options then if not self.options then
-- empty table to hold the bar options
self.options = {} self.options = {}
-- template for disabled bars
self.disabledoptions = { self.disabledoptions = {
general = { general = {
type = "group", type = "group",
@@ -103,16 +108,16 @@ function BT4ActionBars:SetupOptions()
} }
} }
-- iterate over bars and create their option tables
for i=1,10 do for i=1,10 do
local config = self.db.profile.actionbars[i] local config = self.db.profile.actionbars[i]
if config.enabled then if config.enabled then
self:CreateBarOption(i, self:GetOptionsTable()) self:CreateBarOption(i)
else else
self:CreateBarOption(i, self.disabledoptions) self:CreateBarOption(i, self.disabledoptions)
end end
end end
end end
return self.options
end end
-- Applys the config in the current profile to all active Bars -- Applys the config in the current profile to all active Bars
@@ -159,6 +164,11 @@ end
function BT4ActionBars:CreateBarOption(id, options) function BT4ActionBars:CreateBarOption(id, options)
if not self.options then return end if not self.options then return end
if not options then
options = self:GetOptionsTable()
end
id = tostring(id) id = tostring(id)
if not self.options[id] then if not self.options[id] then
self.options[id] = { self.options[id] = {
@@ -170,6 +180,8 @@ function BT4ActionBars:CreateBarOption(id, options)
} }
end end
self.options[id].args = options self.options[id].args = options
-- register options in the BT GUI
Bartender4:RegisterBarOptions(id, self.options[id]) Bartender4:RegisterBarOptions(id, self.options[id])
end end
@@ -192,7 +204,7 @@ function BT4ActionBars:Create(id, config)
local bar = setmetatable(Bartender4.ButtonBar:Create(id, "SecureStateHeaderTemplate", config), ActionBar_MT) local bar = setmetatable(Bartender4.ButtonBar:Create(id, "SecureStateHeaderTemplate", config), ActionBar_MT)
bar.module = self bar.module = self
self:CreateBarOption(id, self:GetOptionsTable()) self:CreateBarOption(id)
bar:ApplyConfig() bar:ApplyConfig()
@@ -220,7 +232,7 @@ function BT4ActionBars:EnableBar(id)
self.actionbars[id] = bar self.actionbars[id] = bar
else else
bar.disabled = nil bar.disabled = nil
self:CreateBarOption(id, self:GetOptionsTable()) self:CreateBarOption(id)
bar:ApplyConfig(config) bar:ApplyConfig(config)
end end
if not Bartender4.Locked then if not Bartender4.Locked then