more option fun
This commit is contained in:
+12
-1
@@ -64,7 +64,7 @@ end
|
||||
function ActionBar:UpdateButtonLayout()
|
||||
local numbuttons = self.config.Buttons
|
||||
local buttons = self.buttons
|
||||
local pad = self.config.Padding
|
||||
local pad = self:GetPadding()
|
||||
|
||||
local Rows = self.config.Rows
|
||||
local ButtonPerRow = math_floor(numbuttons / Rows + 0.5) -- just a precaution
|
||||
@@ -86,6 +86,17 @@ function ActionBar:UpdateButtonLayout()
|
||||
end
|
||||
end
|
||||
|
||||
function ActionBar:GetPadding()
|
||||
return self.config.Padding
|
||||
end
|
||||
|
||||
function ActionBar:SetPadding(pad)
|
||||
if pad then
|
||||
self.config.Padding = pad
|
||||
end
|
||||
self:UpdateButtonLayout()
|
||||
end
|
||||
|
||||
function ActionBar:GetAll()
|
||||
return pairs(self.buttons)
|
||||
end
|
||||
|
||||
+56
-29
@@ -149,48 +149,78 @@ function BT4ActionBars:SetupOptions()
|
||||
Bartender4:RegisterModuleOptions("actionbars", self.options)
|
||||
end
|
||||
|
||||
function BT4ActionBars:GetOptionSubTables()
|
||||
local getBar, optGetter, optSetter, optionMap, callFunc
|
||||
do
|
||||
optionMap = {
|
||||
padding = "Padding",
|
||||
}
|
||||
|
||||
function getBar(id)
|
||||
local bar = BT4ActionBars.actionbars[tonumber(id)]
|
||||
assert(bar, "Invalid bar id in options table.")
|
||||
return bar
|
||||
end
|
||||
|
||||
function callFunc(bar, type, option, ...)
|
||||
local func = type .. (optionMap[option] or option)
|
||||
assert(bar[func], "Invalid get/set function."..func)
|
||||
return bar[func](bar, ...)
|
||||
end
|
||||
|
||||
function optGetter(info)
|
||||
local bar = getBar(info[2])
|
||||
local option = info[#info]
|
||||
return callFunc(bar, "Get", option)
|
||||
end
|
||||
|
||||
function optSetter(info, ...)
|
||||
local bar = getBar(info[2])
|
||||
local option = info[#info]
|
||||
return callFunc(bar, "Set", option, ...)
|
||||
end
|
||||
end
|
||||
|
||||
function BT4ActionBars:GetOptionsTable()
|
||||
local styleoptions, alignoptions = Bartender4.Bar:GetOptionSubTables("style"), Bartender4.Bar:GetOptionSubTables("align")
|
||||
local buttonoptions, stanceoptions, swapoptions = self:GetOptionSubTables()
|
||||
if not self.baroptions then
|
||||
self.baroptions = {
|
||||
self.baroptions = Bartender4:Merge({
|
||||
general = {
|
||||
-- type = inherited
|
||||
-- name = inherited
|
||||
-- cmdInline = inherited
|
||||
order = 1,
|
||||
type = "group",
|
||||
name = "General Options",
|
||||
cmdInline = true,
|
||||
plugins = {
|
||||
bar = styleoptions,
|
||||
button = buttonoptions,
|
||||
args = {
|
||||
style = {
|
||||
-- type = inherited
|
||||
-- name = inherited
|
||||
-- inline = inherited
|
||||
args = {
|
||||
padding = {
|
||||
type = "range",
|
||||
name = "Padding",
|
||||
desc = "Configure the padding of the buttons.",
|
||||
min = -10, max = 20, step = 1,
|
||||
set = optSetter,
|
||||
get = optGetter,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
args = {},
|
||||
},
|
||||
swap = {
|
||||
type = "group",
|
||||
name = "Page Swapping",
|
||||
order = 5,
|
||||
plugins = {
|
||||
stance = stanceoptions,
|
||||
swap = swapoptions,
|
||||
},
|
||||
args = {
|
||||
},
|
||||
cmdInline = true,
|
||||
order = 2,
|
||||
args = {},
|
||||
},
|
||||
align = {
|
||||
-- type = inherited
|
||||
-- name = inherited
|
||||
-- cmdInline = inherited
|
||||
order = 3,
|
||||
type = "group",
|
||||
name = "Alignment",
|
||||
cmdInline = true,
|
||||
plugins = {
|
||||
align = alignoptions,
|
||||
},
|
||||
args = {},
|
||||
}
|
||||
}
|
||||
}, Bartender4.Bar:GetOptionTable())
|
||||
end
|
||||
|
||||
return self.baroptions
|
||||
@@ -208,10 +238,7 @@ function BT4ActionBars:Create(id, config)
|
||||
type = "group",
|
||||
name = ("Bar %s"):format(id),
|
||||
desc = ("Configure Bar %s"):format(id),
|
||||
plugins = {
|
||||
bar = options,
|
||||
},
|
||||
args = {},
|
||||
args = options,
|
||||
childGroups = "tab",
|
||||
}
|
||||
|
||||
|
||||
@@ -22,9 +22,8 @@ Bartender4.Bar.defaults = defaults
|
||||
Bartender4.Bar.prototype = Bar
|
||||
function Bartender4.Bar:Create(id, template, config)
|
||||
id = tostring(id)
|
||||
if barregistry[id] then
|
||||
error(("A bar with id %s has already been registered."):format(id), 2)
|
||||
end
|
||||
assert(not barregistry[id], "duplicated entry in barregistry.")
|
||||
|
||||
local bar = setmetatable(CreateFrame("Button", ("BT4Bar%s"):format(id), UIParent, template), Bar_MT)
|
||||
barregistry[id] = bar
|
||||
bar.id = id
|
||||
@@ -55,7 +54,7 @@ function Bartender4.Bar:Create(id, template, config)
|
||||
return bar
|
||||
end
|
||||
|
||||
local getBar, optGetter, optSetter, optionMap
|
||||
local getBar, optGetter, optSetter, optionMap, callFunc
|
||||
do
|
||||
optionMap = {
|
||||
alpha = "ConfigAlpha",
|
||||
@@ -87,50 +86,54 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
function Bartender4.Bar:GetOptionSubTables(table)
|
||||
function Bartender4.Bar:GetOptionTable()
|
||||
if not self.options then
|
||||
self.options = {
|
||||
style = {
|
||||
style = {
|
||||
type = "group",
|
||||
inline = true,
|
||||
name = "Style",
|
||||
args = {
|
||||
alpha = {
|
||||
name = "Alpha",
|
||||
desc = "Configure the alpha of the bar.",
|
||||
type = "range",
|
||||
min = .1, max = 1, bigStep = 0.1,
|
||||
get = optGetter,
|
||||
set = optSetter,
|
||||
},
|
||||
scale = {
|
||||
name = "Scale",
|
||||
desc = "Configure the scale of the bar.",
|
||||
type = "range",
|
||||
min = .1, max = 2, step = 0.05, bigStep = 0.1,
|
||||
get = optGetter,
|
||||
set = optSetter,
|
||||
general = {
|
||||
type = "group",
|
||||
cmdInline = true,
|
||||
name = "General Settings",
|
||||
order = 1,
|
||||
args = {
|
||||
style = {
|
||||
type = "group",
|
||||
name = "Style",
|
||||
inline = true,
|
||||
order = 5,
|
||||
args = {
|
||||
alpha = {
|
||||
name = "Alpha",
|
||||
desc = "Configure the alpha of the bar.",
|
||||
type = "range",
|
||||
min = .1, max = 1, bigStep = 0.1,
|
||||
get = optGetter,
|
||||
set = optSetter,
|
||||
},
|
||||
scale = {
|
||||
name = "Scale",
|
||||
desc = "Configure the scale of the bar.",
|
||||
type = "range",
|
||||
min = .1, max = 2, step = 0.05, bigStep = 0.1,
|
||||
get = optGetter,
|
||||
set = optSetter,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
align = {
|
||||
align = {
|
||||
type = "group",
|
||||
inline = true,
|
||||
name = "Alignment",
|
||||
args = {
|
||||
|
||||
}
|
||||
}
|
||||
type = "group",
|
||||
cmdInline = true,
|
||||
name = "Alignment",
|
||||
order = 10,
|
||||
args = {
|
||||
|
||||
},
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
assert(self.options[table], "Invalid options sub-table.")
|
||||
|
||||
return self.options[table]
|
||||
return self.options
|
||||
end
|
||||
|
||||
local barOnEnter, barOnLeave, barOnDragStart, barOnDragStop, barOnClick
|
||||
|
||||
+2
-1
@@ -18,6 +18,7 @@ function Bartender4:SetupOptions()
|
||||
name = "Bartender4",
|
||||
icon = "Interface\\Icons\\INV_Drink_05",
|
||||
childGroups = "tree",
|
||||
plugins = {},
|
||||
args = {
|
||||
gui = {
|
||||
type = "execute",
|
||||
@@ -42,5 +43,5 @@ function Bartender4:SetupOptions()
|
||||
end
|
||||
|
||||
function Bartender4:RegisterModuleOptions(key, table)
|
||||
self.options.args[key] = table
|
||||
self.options.plugins[key] = { [key] = table }
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user