option stuff

This commit is contained in:
Hendrik Leppkes
2007-12-08 16:38:57 +00:00
parent cf182cdd74
commit ed969c26fe
3 changed files with 94 additions and 33 deletions
+34 -6
View File
@@ -149,17 +149,47 @@ function BT4ActionBars:SetupOptions()
Bartender4:RegisterModuleOptions("actionbars", self.options)
end
function BT4ActionBars:GetOptionSubTables()
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 = {
general = {
order = 1,
type = "group",
name = "General Options",
cmdInline = true,
plugins = {
bar = styleoptions,
button = buttonoptions,
},
args = {},
},
swap = {
type = "group",
name = "Page Swapping",
order = 5,
plugins = {
stance = stanceoptions,
swap = swapoptions,
},
args = {
},
},
align = {
order = 3,
type = "group",
name = "Alignment",
cmdInline = true,
plugins = {
align = alignoptions,
},
args = {},
}
}
end
@@ -171,8 +201,7 @@ function BT4ActionBars:Create(id, config)
local id = tostring(id)
local bar = setmetatable(Bartender4.Bar:Create(id, "SecureStateHeaderTemplate", config), ActionBar_MT)
local baroptions = Bartender4.Bar:GetOptionsTable()
local actionbaroptions = self:GetOptionsTable()
local options = self:GetOptionsTable()
self.options.args[id] = {
order = 10 + tonumber(id),
@@ -180,10 +209,9 @@ function BT4ActionBars:Create(id, config)
name = ("Bar %s"):format(id),
desc = ("Configure Bar %s"):format(id),
plugins = {
bar = baroptions,
actionbar = actionbaroptions,
bar = options,
},
args = { },
args = {},
childGroups = "tab",
}
+52 -27
View File
@@ -58,7 +58,8 @@ end
local getBar, optGetter, optSetter, optionMap
do
optionMap = {
alpha = "Alpha",
alpha = "ConfigAlpha",
scale = "ConfigScale",
}
function getBar(id)
@@ -68,55 +69,68 @@ do
end
function callFunc(bar, type, option, ...)
local func = type .. "Config" .. optionMap[option]
local func = type .. (optionMap[option] or option)
assert(bar[func], "Invalid get/set function.")
return bar[func](bar, ...)
end
function optGetter(info)
local bar = getBar(info[#info-2])
local bar = getBar(info[2])
local option = info[#info]
return callFunc(bar, "Get", option)
end
function optSetter(info, ...)
local bar = getBar(info[#info-2])
local bar = getBar(info[2])
local option = info[#info]
return callFunc(bar, "Set", option, ...)
end
end
function Bartender4.Bar:GetOptionsTable()
function Bartender4.Bar:GetOptionSubTables(table)
if not self.options then
self.options = {
general = {
order = 1,
type = "group",
name = "General Options",
cmdInline = true,
args = {
alpha = {
name = "Alpha",
desc = "Configure the alpha of the bar.",
type = "range",
min = .1, max = 1, bigStep = 0.1,
get = optGetter,
set = optSetter,
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,
},
},
}
},
},
align = {
order = 10,
type = "group",
name = "Alignment",
args = {
align = {
type = "group",
inline = true,
name = "Alignment",
args = {
}
}
},
}
end
return self.options
assert(self.options[table], "Invalid options sub-table.")
return self.options[table]
end
local barOnEnter, barOnLeave, barOnDragStart, barOnDragStop, barOnClick
@@ -190,7 +204,7 @@ end
function Bar:LoadPosition()
if not self.config.Position then return end
local pos = self.config.Position
local x, y, s = pos.x, pos.y, UIParent:GetEffectiveScale()
local x, y, s = pos.x, pos.y, self:GetEffectiveScale()
local point, relPoint = pos.point, pos.relPoint
x, y = x/s, y/s
self:ClearSetPoint(point, UIParent, relPoint, x, y)
@@ -200,7 +214,7 @@ function Bar:SavePosition()
if not self.config.Position then self.config.Position = {} end
local pos = self.config.Position
local point, parent, relPoint, x, y = self:GetPoint()
local s = UIParent:GetEffectiveScale()
local s = self:GetEffectiveScale()
x, y = x*s, y*s
pos.x, pos.y = x, y
pos.point, pos.relPoint = point, relPoint
@@ -222,6 +236,17 @@ function Bar:SetConfigAlpha(alpha)
self:SetAlpha(self.config.Alpha)
end
function Bar:GetConfigScale()
return self.config.Scale
end
function Bar:SetConfigScale(scale)
if scale then
self.config.Scale = scale
end
self:SetScale(self.config.Scale)
self:LoadPosition()
end
--[[
Lazyness functions
+8
View File
@@ -291,6 +291,14 @@ function Button:HideButton()
self.highlightTexture:SetTexture("")
end
function Button:ShowGrid()
end
function Button:HideGrid()
end
function Button:RegisterButtonEvents()
self:RegisterEvent("ACTIONBAR_SLOT_CHANGED")
self:RegisterEvent("PLAYER_ENTERING_WORLD")