- build the config on demand (might break stuff, srsly)

- add options for configuring the modifier switching
This commit is contained in:
Hendrik Leppkes
2008-04-08 10:31:40 +00:00
parent 7bed8cdf21
commit b6adf401f6
6 changed files with 221 additions and 127 deletions
+55 -4
View File
@@ -25,6 +25,7 @@ do
stance = "StanceStateOption",
enabled = "StateOption",
def_state = "DefaultState",
states = "StateOption",
}
-- retrieves a valid bar object from the modules actionbars table
function getBar(id)
@@ -83,14 +84,17 @@ local function createOptionGroup(k, id)
order = 10 * k,
type = "select",
arg = "stance",
get = optGetter,
set = optSetter,
values = validStanceTable,
name = module.DefaultStanceMap[playerclass][k].name,
}
return tbl
end
local disabledFunc = function(info)
local bar = module.actionbars[tonumber(info[2])]
return not bar:GetStateOption("enabled")
end
function module:GetStateOptionsTable()
local options = {
enabled = {
@@ -113,6 +117,50 @@ function module:GetStateOptionsTable()
values = validStanceTable,
get = optGetter,
set = optSetter,
disabled = disabledFunc,
},
modifiers = {
order = 30,
type = "group",
inline = true,
name = "",
get = optGetter,
set = optSetter,
disabled = disabledFunc,
args = {
header = {
order = 1,
type = "header",
name = "Modifier Based Switching",
},
ctrl = {
order = 10,
type = "select",
name = "CTRL",
arg = "states",
values = validStanceTable,
desc = "Configure actionbar paging when the ctrl key is down.",
--width = "half",
},
alt = {
order = 15,
type = "select",
name = "ALT",
arg = "states",
values = validStanceTable,
desc = "Configure actionbar paging when the alt key is down.",
--width = "half",
},
shift = {
order = 20,
type = "select",
name = "SHIFT",
arg = "states",
values = validStanceTable,
desc = "Configure actionbar paging when the shift key is down.",
--width = "half",
},
},
},
stances = {
order = 20,
@@ -120,6 +168,9 @@ function module:GetStateOptionsTable()
inline = true,
name = "",
hidden = function() return not (module.DefaultStanceMap[playerclass]) end,
get = optGetter,
set = optSetter,
disabled = disabledFunc,
args = {
stance_header = {
order = 1,
@@ -310,10 +361,10 @@ function ActionBar:SetStateOption(key, value)
end
function ActionBar:GetDefaultState()
return self.config.states.stance.default
return self.config.states.default
end
function ActionBar:SetDefaultState(_, value)
self.config.states.stance.default = value
self.config.states.default = value
self:UpdateStates()
end
+39 -26
View File
@@ -12,8 +12,11 @@ local abdefaults = {
showgrid = false,
states = {
enabled = false,
default = 0,
ctrl = 0,
alt = 0,
shift = 0,
stance = {
default = 0,
['**'] = {
['*'] = 0,
},
@@ -53,9 +56,6 @@ local defaults = {
function BT4ActionBars:OnInitialize()
self.db = Bartender4.db:RegisterNamespace("ActionBars", defaults)
self:SetupOptions()
-- fetch the prototype information
ActionBar = Bartender4.ActionBar
ActionBar_MT = {__index = ActionBar}
@@ -81,6 +81,40 @@ function BT4ActionBars:OnEnable()
self:ReassignBindings()
end
function BT4ActionBars:SetupOptions()
if not self.options then
self.options = {}
self.disabledoptions = {
general = {
type = "group",
name = "General Settings",
cmdInline = true,
order = 1,
args = {
enabled = {
type = "toggle",
name = "Enabled",
desc = "Enable/Disable the bar.",
set = function(info, v) if v then BT4ActionBars:EnableBar(info[2]) end end,
get = function() return false end,
}
}
}
}
for i=1,10 do
local config = self.db.profile.actionbars[i]
if config.enabled then
self:CreateBarOption(i, self:GetOptionsTable())
else
self:CreateBarOption(i, self.disabledoptions)
end
end
end
return self.options
end
-- Applys the config in the current profile to all active Bars
function BT4ActionBars:ApplyConfig()
for i=1,10 do
@@ -123,29 +157,8 @@ function BT4ActionBars:ForAllButtons(...)
self:ForAll("ForAll", ...)
end
function BT4ActionBars:SetupOptions()
self.options = {}
self.disabledoptions = {
general = {
type = "group",
name = "General Settings",
cmdInline = true,
order = 1,
args = {
enabled = {
type = "toggle",
name = "Enabled",
desc = "Enable/Disable the bar.",
set = function(info, v) if v then BT4ActionBars:EnableBar(info[2]) end end,
get = function() return false end,
}
}
}
}
end
function BT4ActionBars:CreateBarOption(id, options)
if not self.options then return end
id = tostring(id)
if not self.options[id] then
self.options[id] = {
+8 -3
View File
@@ -20,7 +20,6 @@ local defaults = { profile = Bartender4:Merge({
function MicroMenuMod:OnInitialize()
self.db = Bartender4.db:RegisterNamespace("MicroMenu", defaults)
self:SetEnabledState(self.db.profile.enabled)
self:SetupOptions()
end
local noopFunc = function() end
@@ -53,7 +52,7 @@ function MicroMenuMod:OnEnable()
self.bar:ApplyConfig(self.db.profile)
end
self.bar.disabled = nil
self:SetupOptions()
self:ToggleOptions()
end
function MicroMenuMod:OnDisable()
@@ -61,7 +60,7 @@ function MicroMenuMod:OnDisable()
self.bar.disabled = true
self.bar:UnregisterAllEvents()
self.bar:Hide()
self:SetupOptions()
self:ToggleOptions()
end
function MicroMenuMod:ApplyConfig()
@@ -105,6 +104,12 @@ function MicroMenuMod:SetupOptions()
self.options.args = self:IsEnabled() and self.optionobject.table or self.disabledoptions
end
function MicroMenuMod:ToggleOptions()
if self.options then
self.options.args = self:IsEnabled() and self.optionobject.table or self.disabledoptions
end
end
function MicroMenuBar:ApplyConfig(config)
Bar.ApplyConfig(self, config)
self:PerformLayout()
+103 -88
View File
@@ -14,97 +14,106 @@ do
end
end
function Bartender4:SetupOptions()
self.options = {
type = "group",
name = "Bartender4",
icon = "Interface\\Icons\\INV_Drink_05",
childGroups = "tree",
plugins = {},
args = {
lock = {
order = 1,
type = "toggle",
name = "Lock",
desc = "Lock all bars.",
get = function() return Bartender4.Locked end,
set = function(info, value) Bartender4[value and "Lock" or "Unlock"](Bartender4) end,
},
buttonlock = {
order = 2,
type = "toggle",
name = "Button Lock",
desc = "Lock the buttons.",
get = getFunc,
set = setFunc,
},
bars = {
order = 20,
type = "group",
name = "Bars",
args = {
range = {
order = 1,
name = "Out of Range Indicator",
desc = "Configure how the Out of Range Indicator should display on the buttons.",
type = "select",
style = "dropdown",
get = function()
return Bartender4.db.profile.outofrange
end,
set = function(info, value)
Bartender4.db.profile.outofrange = value
Bartender4.Bar:ForAll("ApplyConfig")
end,
values = { none = "No Display", button = "Full Button Mode", hotkey = "Hotkey Mode" },
},
colors = {
order = 3,
type = "group",
guiInline = true,
name = "Colors",
get = function(info)
local color = Bartender4.db.profile.colors[info[#info]]
return color.r, color.g, color.b
end,
set = function(info, r, g, b)
local color = Bartender4.db.profile.colors[info[#info]]
color.r, color.g, color.b = r, g, b
Bartender4.Bar:ForAll("ApplyConfig")
end,
args = {
range = {
order = 1,
type = "color",
name = "Out of Range Indicator",
desc = "Specify the Color of the Out of Range Indicator",
},
mana = {
order = 2,
type = "color",
name = "Out of Mana Indicator",
desc = "Specify the Color of the Out of Mana Indicator",
local function getOptions()
if not Bartender4.options then
Bartender4.options = {
type = "group",
name = "Bartender4",
icon = "Interface\\Icons\\INV_Drink_05",
childGroups = "tree",
plugins = {},
args = {
lock = {
order = 1,
type = "toggle",
name = "Lock",
desc = "Lock all bars.",
get = function() return Bartender4.Locked end,
set = function(info, value) Bartender4[value and "Lock" or "Unlock"](Bartender4) end,
},
buttonlock = {
order = 2,
type = "toggle",
name = "Button Lock",
desc = "Lock the buttons.",
get = getFunc,
set = setFunc,
},
bars = {
order = 20,
type = "group",
name = "Bars",
args = {
range = {
order = 1,
name = "Out of Range Indicator",
desc = "Configure how the Out of Range Indicator should display on the buttons.",
type = "select",
style = "dropdown",
get = function()
return Bartender4.db.profile.outofrange
end,
set = function(info, value)
Bartender4.db.profile.outofrange = value
Bartender4.Bar:ForAll("ApplyConfig")
end,
values = { none = "No Display", button = "Full Button Mode", hotkey = "Hotkey Mode" },
},
colors = {
order = 3,
type = "group",
guiInline = true,
name = "Colors",
get = function(info)
local color = Bartender4.db.profile.colors[info[#info]]
return color.r, color.g, color.b
end,
set = function(info, r, g, b)
local color = Bartender4.db.profile.colors[info[#info]]
color.r, color.g, color.b = r, g, b
Bartender4.Bar:ForAll("ApplyConfig")
end,
args = {
range = {
order = 1,
type = "color",
name = "Out of Range Indicator",
desc = "Specify the Color of the Out of Range Indicator",
},
mana = {
order = 2,
type = "color",
name = "Out of Mana Indicator",
desc = "Specify the Color of the Out of Mana Indicator",
},
},
},
tooltip = {
order = 2,
name = "Button Tooltip",
type = "select",
desc = "Configure the Button Tooltip.",
values = { ["disabled"] = "Disabled", ["nocombat"] = "Disabled in Combat", ["enabled"] = "Enabled" },
get = function() return Bartender4.db.profile.tooltip end,
set = function(info, value) Bartender4.db.profile.tooltip = value end,
},
},
tooltip = {
order = 2,
name = "Button Tooltip",
type = "select",
desc = "Configure the Button Tooltip.",
values = { ["disabled"] = "Disabled", ["nocombat"] = "Disabled in Combat", ["enabled"] = "Enabled" },
get = function() return Bartender4.db.profile.tooltip end,
set = function(info, value) Bartender4.db.profile.tooltip = value end,
},
},
}
},
}
self.options.plugins.profiles = { profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db) }
LibStub("AceConfig-3.0"):RegisterOptionsTable("Bartender4", self.options, "bttest")
}
},
}
Bartender4.options.plugins.profiles = { profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(Bartender4.db) }
for k,v in Bartender4:IterateModules() do
if v.SetupOptions then
v:SetupOptions()
end
end
end
return Bartender4.options
end
function Bartender4:SetupOptions()
LibStub("AceConfig-3.0"):RegisterOptionsTable("Bartender4", getOptions, "bttest")
AceConfigDialog:SetDefaultSize("Bartender4", 680,525)
local optFunc = function()
if InCombatLockdown() then return end
AceConfigDialog:Open("Bartender4")
@@ -121,10 +130,16 @@ function Bartender4:SetupOptions()
end
function Bartender4:RegisterModuleOptions(key, table)
if not self.options then
error("Options table has not been created yet, respond to the callback!", 2)
end
self.options.plugins[key] = { [key] = table }
end
function Bartender4:RegisterBarOptions(id, table)
if not self.options then
error("Options table has not been created yet, respond to the callback!", 2)
end
self.options.args.bars.args[id] = table
end
+8 -3
View File
@@ -20,7 +20,6 @@ local defaults = { profile = Bartender4:Merge({
function PetBarMod:OnInitialize()
self.db = Bartender4.db:RegisterNamespace("PetBar", defaults)
self:SetEnabledState(self.db.profile.enabled)
self:SetupOptions()
end
function PetBarMod:OnEnable()
@@ -56,7 +55,7 @@ function PetBarMod:OnEnable()
self.bar:RegisterEvent("PET_BAR_HIDEGRID")
self:ApplyConfig()
self:SetupOptions()
self:ToggleOptions()
self:RegisterEvent("UPDATE_BINDINGS", "ReassignBindings")
self:ReassignBindings()
@@ -70,7 +69,7 @@ function PetBarMod:OnDisable()
self.bar:UnregisterAllEvents()
self.bar:Hide()
self:SetupOptions()
self:ToggleOptions()
end
local function onEnter(self, ...)
@@ -149,6 +148,12 @@ function PetBarMod:SetupOptions()
self.options.args = self:IsEnabled() and self.optionobject.table or self.disabledoptions
end
function PetBarMod:ToggleOptions()
if self.options then
self.options.args = self:IsEnabled() and self.optionobject.table or self.disabledoptions
end
end
function PetBarMod:ReassignBindings()
if not self.bar or not self.bar.buttons then return end
ClearOverrideBindings(self.bar)
+8 -3
View File
@@ -22,7 +22,6 @@ local defaults = { profile = Bartender4:Merge({
function StanceBarMod:OnInitialize()
self.db = Bartender4.db:RegisterNamespace("StanceBar", defaults)
self:SetEnabledState(self.db.profile.enabled)
self:SetupOptions()
end
function StanceBarMod:OnEnable()
@@ -33,7 +32,7 @@ function StanceBarMod:OnEnable()
self.bar:ApplyConfig()
self.bar:SetScript("OnEvent", StanceBar.OnEvent)
end
self:SetupOptions()
self:ToggleOptions()
self.bar:RegisterEvent("PLAYER_ENTERING_WORLD")
self.bar:RegisterEvent("UPDATE_SHAPESHIFT_FORMS")
self.bar:RegisterEvent("SPELL_UPDATE_COOLDOWN")
@@ -49,7 +48,7 @@ function StanceBarMod:OnDisable()
if not self.bar then return end
self.bar:UnregisterAllEvents()
self.bar:Hide()
self:SetupOptions()
self:ToggleOptions()
end
function StanceBarMod:SetupOptions()
@@ -92,6 +91,12 @@ function StanceBarMod:SetupOptions()
self.options.args = self:IsEnabled() and self.optionobject.table or self.disabledoptions
end
function StanceBarMod:ToggleOptions()
if self.options then
self.options.args = self:IsEnabled() and self.optionobject.table or self.disabledoptions
end
end
function StanceBarMod:ApplyConfig()
if not self:IsEnabled() then return end
self.bar:ApplyConfig(self.db.profile)