use db namespaces to store the actionbar configs, zomgmoremodular
This commit is contained in:
+18
-15
@@ -10,7 +10,7 @@ local stancedefaults = {
|
|||||||
ROGUE = { stealth = 7 }
|
ROGUE = { stealth = 7 }
|
||||||
}
|
}
|
||||||
|
|
||||||
local defaults = Bartender4:Merge({
|
local abdefaults = Bartender4:Merge({
|
||||||
['**'] = {
|
['**'] = {
|
||||||
Enabled = true,
|
Enabled = true,
|
||||||
Buttons = 12,
|
Buttons = 12,
|
||||||
@@ -35,9 +35,17 @@ local defaults = Bartender4:Merge({
|
|||||||
},
|
},
|
||||||
}, Bartender4.Bar.defaults)
|
}, Bartender4.Bar.defaults)
|
||||||
|
|
||||||
|
local defaults = {
|
||||||
|
profile = {
|
||||||
|
OutOfRange = "button",
|
||||||
|
Colors = { range = { r = 0.8, g = 0.1, b = 0.1 }, mana = { r = 0.5, g = 0.5, b = 1.0 } },
|
||||||
|
ActionBars = abdefaults,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function BT4ActionBars:OnInitialize()
|
function BT4ActionBars:OnInitialize()
|
||||||
self.db = Bartender4.db
|
self.db = Bartender4.db:RegisterNamespace("ActionBars", defaults)
|
||||||
Bartender4:RegisterDefaultsKey("ActionBars", defaults)
|
|
||||||
|
|
||||||
self:SetupOptions()
|
self:SetupOptions()
|
||||||
|
|
||||||
@@ -101,14 +109,6 @@ function BT4ActionBars:ForAllButtons(...)
|
|||||||
self:ForAll("ForAll", ...)
|
self:ForAll("ForAll", ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
local getFunc
|
|
||||||
do
|
|
||||||
function getFunc(info)
|
|
||||||
local key = info.arg or info[#info]
|
|
||||||
return Bartender4.db.profile[key]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function BT4ActionBars:SetupOptions()
|
function BT4ActionBars:SetupOptions()
|
||||||
self.options = {
|
self.options = {
|
||||||
order = 20,
|
order = 20,
|
||||||
@@ -129,9 +129,11 @@ function BT4ActionBars:SetupOptions()
|
|||||||
desc = "Configure how the Out of Range Indicator should display on the buttons.",
|
desc = "Configure how the Out of Range Indicator should display on the buttons.",
|
||||||
type = "select",
|
type = "select",
|
||||||
style = "dropdown",
|
style = "dropdown",
|
||||||
arg = "OutOfRange",
|
get = function()
|
||||||
|
return BT4ActionBars.db.profile.OutOfRange
|
||||||
|
end,
|
||||||
set = function(info, value)
|
set = function(info, value)
|
||||||
Bartender4.db.profile.OutOfRange = value
|
BT4ActionBars.db.profile.OutOfRange = value
|
||||||
BT4ActionBars:ForAllButtons("UpdateUsable")
|
BT4ActionBars:ForAllButtons("UpdateUsable")
|
||||||
end,
|
end,
|
||||||
values = { none = "No Display", button = "Full Button Mode", hotkey = "Hotkey Mode" },
|
values = { none = "No Display", button = "Full Button Mode", hotkey = "Hotkey Mode" },
|
||||||
@@ -142,11 +144,11 @@ function BT4ActionBars:SetupOptions()
|
|||||||
guiInline = true,
|
guiInline = true,
|
||||||
name = "Colors",
|
name = "Colors",
|
||||||
get = function(info)
|
get = function(info)
|
||||||
local color = Bartender4.db.profile.Colors[info[#info]]
|
local color = BT4ActionBars.db.profile.Colors[info[#info]]
|
||||||
return color.r, color.g, color.b
|
return color.r, color.g, color.b
|
||||||
end,
|
end,
|
||||||
set = function(info, r, g, b)
|
set = function(info, r, g, b)
|
||||||
local color = Bartender4.db.profile.Colors[info[#info]]
|
local color = BT4ActionBars.db.profile.Colors[info[#info]]
|
||||||
color.r, color.g, color.b = r, g, b
|
color.r, color.g, color.b = r, g, b
|
||||||
BT4ActionBars:ForAllButtons("UpdateUsable")
|
BT4ActionBars:ForAllButtons("UpdateUsable")
|
||||||
end,
|
end,
|
||||||
@@ -201,6 +203,7 @@ end
|
|||||||
function BT4ActionBars:Create(id, config)
|
function BT4ActionBars:Create(id, config)
|
||||||
local id = tostring(id)
|
local id = tostring(id)
|
||||||
local bar = setmetatable(Bartender4.Bar:Create(id, "SecureStateHeaderTemplate", config), ActionBar_MT)
|
local bar = setmetatable(Bartender4.Bar:Create(id, "SecureStateHeaderTemplate", config), ActionBar_MT)
|
||||||
|
bar.module = self
|
||||||
|
|
||||||
self:CreateBarOption(id, self:GetOptionsTable())
|
self:CreateBarOption(id, self:GetOptionsTable())
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -4,8 +4,7 @@ Bartender4 = AceAddon:NewAddon("Bartender4", "AceConsole-3.0", "AceEvent-3.0")
|
|||||||
|
|
||||||
local defaults = {
|
local defaults = {
|
||||||
profile = {
|
profile = {
|
||||||
OutOfRange = "button",
|
|
||||||
Colors = { range = { r = 0.8, g = 0.1, b = 0.1 }, mana = { r = 0.5, g = 0.5, b = 1.0 } },
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -16,6 +16,7 @@ function Bartender4.Button:Create(id, parent)
|
|||||||
local name = ("BT4Button%d"):format(absid)
|
local name = ("BT4Button%d"):format(absid)
|
||||||
local button = setmetatable(CreateFrame("CheckButton", name, parent, "SecureActionButtonTemplate, ActionButtonTemplate"), Button_MT)
|
local button = setmetatable(CreateFrame("CheckButton", name, parent, "SecureActionButtonTemplate, ActionButtonTemplate"), Button_MT)
|
||||||
button.parent = parent
|
button.parent = parent
|
||||||
|
button.settings = parent.module.db
|
||||||
|
|
||||||
button:SetScript("OnEvent", button.EventHandler)
|
button:SetScript("OnEvent", button.EventHandler)
|
||||||
button:SetScript("OnUpdate", onUpdate)
|
button:SetScript("OnUpdate", onUpdate)
|
||||||
@@ -216,9 +217,9 @@ function Button:UpdateState()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Button:UpdateUsable()
|
function Button:UpdateUsable()
|
||||||
local oor = Bartender4.db.profile.OutOfRange
|
local oor = self.settings.profile.OutOfRange
|
||||||
local isUsable, notEnoughMana = IsUsableAction(self.action)
|
local isUsable, notEnoughMana = IsUsableAction(self.action)
|
||||||
local oorcolor, oomcolor = Bartender4.db.profile.Colors.range, Bartender4.db.profile.Colors.mana
|
local oorcolor, oomcolor = self.settings.profile.Colors.range, self.settings.profile.Colors.mana
|
||||||
if ( oor ~= "button" or not self.outOfRange) then
|
if ( oor ~= "button" or not self.outOfRange) then
|
||||||
if ( oor == "none" or not self.outOfRange) then
|
if ( oor == "none" or not self.outOfRange) then
|
||||||
self.hotkey:SetVertexColor(1.0, 1.0, 1.0)
|
self.hotkey:SetVertexColor(1.0, 1.0, 1.0)
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@ function Bartender4:SetupOptions()
|
|||||||
general = {
|
general = {
|
||||||
order = 10,
|
order = 10,
|
||||||
type = "group",
|
type = "group",
|
||||||
--cmdInline = true,
|
cmdInline = true,
|
||||||
name = "General Settings",
|
name = "General Settings",
|
||||||
get = getFunc,
|
get = getFunc,
|
||||||
set = setFunc,
|
set = setFunc,
|
||||||
|
|||||||
Reference in New Issue
Block a user