- 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", stance = "StanceStateOption",
enabled = "StateOption", enabled = "StateOption",
def_state = "DefaultState", def_state = "DefaultState",
states = "StateOption",
} }
-- retrieves a valid bar object from the modules actionbars table -- retrieves a valid bar object from the modules actionbars table
function getBar(id) function getBar(id)
@@ -83,14 +84,17 @@ local function createOptionGroup(k, id)
order = 10 * k, order = 10 * k,
type = "select", type = "select",
arg = "stance", arg = "stance",
get = optGetter,
set = optSetter,
values = validStanceTable, values = validStanceTable,
name = module.DefaultStanceMap[playerclass][k].name, name = module.DefaultStanceMap[playerclass][k].name,
} }
return tbl return tbl
end end
local disabledFunc = function(info)
local bar = module.actionbars[tonumber(info[2])]
return not bar:GetStateOption("enabled")
end
function module:GetStateOptionsTable() function module:GetStateOptionsTable()
local options = { local options = {
enabled = { enabled = {
@@ -113,6 +117,50 @@ function module:GetStateOptionsTable()
values = validStanceTable, values = validStanceTable,
get = optGetter, get = optGetter,
set = optSetter, 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 = { stances = {
order = 20, order = 20,
@@ -120,6 +168,9 @@ function module:GetStateOptionsTable()
inline = true, inline = true,
name = "", name = "",
hidden = function() return not (module.DefaultStanceMap[playerclass]) end, hidden = function() return not (module.DefaultStanceMap[playerclass]) end,
get = optGetter,
set = optSetter,
disabled = disabledFunc,
args = { args = {
stance_header = { stance_header = {
order = 1, order = 1,
@@ -310,10 +361,10 @@ function ActionBar:SetStateOption(key, value)
end end
function ActionBar:GetDefaultState() function ActionBar:GetDefaultState()
return self.config.states.stance.default return self.config.states.default
end end
function ActionBar:SetDefaultState(_, value) function ActionBar:SetDefaultState(_, value)
self.config.states.stance.default = value self.config.states.default = value
self:UpdateStates() self:UpdateStates()
end end
+39 -26
View File
@@ -12,8 +12,11 @@ local abdefaults = {
showgrid = false, showgrid = false,
states = { states = {
enabled = false, enabled = false,
stance = {
default = 0, default = 0,
ctrl = 0,
alt = 0,
shift = 0,
stance = {
['**'] = { ['**'] = {
['*'] = 0, ['*'] = 0,
}, },
@@ -53,9 +56,6 @@ local defaults = {
function BT4ActionBars:OnInitialize() function BT4ActionBars:OnInitialize()
self.db = Bartender4.db:RegisterNamespace("ActionBars", defaults) self.db = Bartender4.db:RegisterNamespace("ActionBars", defaults)
self:SetupOptions()
-- fetch the prototype information -- fetch the prototype information
ActionBar = Bartender4.ActionBar ActionBar = Bartender4.ActionBar
ActionBar_MT = {__index = ActionBar} ActionBar_MT = {__index = ActionBar}
@@ -81,6 +81,40 @@ function BT4ActionBars:OnEnable()
self:ReassignBindings() self:ReassignBindings()
end 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 -- Applys the config in the current profile to all active Bars
function BT4ActionBars:ApplyConfig() function BT4ActionBars:ApplyConfig()
for i=1,10 do for i=1,10 do
@@ -123,29 +157,8 @@ function BT4ActionBars:ForAllButtons(...)
self:ForAll("ForAll", ...) self:ForAll("ForAll", ...)
end 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) function BT4ActionBars:CreateBarOption(id, options)
if not self.options then return 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] = {
+8 -3
View File
@@ -20,7 +20,6 @@ local defaults = { profile = Bartender4:Merge({
function MicroMenuMod:OnInitialize() function MicroMenuMod:OnInitialize()
self.db = Bartender4.db:RegisterNamespace("MicroMenu", defaults) self.db = Bartender4.db:RegisterNamespace("MicroMenu", defaults)
self:SetEnabledState(self.db.profile.enabled) self:SetEnabledState(self.db.profile.enabled)
self:SetupOptions()
end end
local noopFunc = function() end local noopFunc = function() end
@@ -53,7 +52,7 @@ function MicroMenuMod:OnEnable()
self.bar:ApplyConfig(self.db.profile) self.bar:ApplyConfig(self.db.profile)
end end
self.bar.disabled = nil self.bar.disabled = nil
self:SetupOptions() self:ToggleOptions()
end end
function MicroMenuMod:OnDisable() function MicroMenuMod:OnDisable()
@@ -61,7 +60,7 @@ function MicroMenuMod:OnDisable()
self.bar.disabled = true self.bar.disabled = true
self.bar:UnregisterAllEvents() self.bar:UnregisterAllEvents()
self.bar:Hide() self.bar:Hide()
self:SetupOptions() self:ToggleOptions()
end end
function MicroMenuMod:ApplyConfig() function MicroMenuMod:ApplyConfig()
@@ -105,6 +104,12 @@ function MicroMenuMod:SetupOptions()
self.options.args = self:IsEnabled() and self.optionobject.table or self.disabledoptions self.options.args = self:IsEnabled() and self.optionobject.table or self.disabledoptions
end 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) function MicroMenuBar:ApplyConfig(config)
Bar.ApplyConfig(self, config) Bar.ApplyConfig(self, config)
self:PerformLayout() self:PerformLayout()
+21 -6
View File
@@ -14,8 +14,9 @@ do
end end
end end
function Bartender4:SetupOptions() local function getOptions()
self.options = { if not Bartender4.options then
Bartender4.options = {
type = "group", type = "group",
name = "Bartender4", name = "Bartender4",
icon = "Interface\\Icons\\INV_Drink_05", icon = "Interface\\Icons\\INV_Drink_05",
@@ -100,11 +101,19 @@ function Bartender4:SetupOptions()
} }
}, },
} }
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
self.options.plugins.profiles = { profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db) } function Bartender4:SetupOptions()
LibStub("AceConfig-3.0"):RegisterOptionsTable("Bartender4", getOptions, "bttest")
AceConfigDialog:SetDefaultSize("Bartender4", 680,525)
LibStub("AceConfig-3.0"):RegisterOptionsTable("Bartender4", self.options, "bttest")
local optFunc = function() local optFunc = function()
if InCombatLockdown() then return end if InCombatLockdown() then return end
AceConfigDialog:Open("Bartender4") AceConfigDialog:Open("Bartender4")
@@ -121,10 +130,16 @@ function Bartender4:SetupOptions()
end end
function Bartender4:RegisterModuleOptions(key, table) 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 } self.options.plugins[key] = { [key] = table }
end end
function Bartender4:RegisterBarOptions(id, table) 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 self.options.args.bars.args[id] = table
end end
+8 -3
View File
@@ -20,7 +20,6 @@ local defaults = { profile = Bartender4:Merge({
function PetBarMod:OnInitialize() function PetBarMod:OnInitialize()
self.db = Bartender4.db:RegisterNamespace("PetBar", defaults) self.db = Bartender4.db:RegisterNamespace("PetBar", defaults)
self:SetEnabledState(self.db.profile.enabled) self:SetEnabledState(self.db.profile.enabled)
self:SetupOptions()
end end
function PetBarMod:OnEnable() function PetBarMod:OnEnable()
@@ -56,7 +55,7 @@ function PetBarMod:OnEnable()
self.bar:RegisterEvent("PET_BAR_HIDEGRID") self.bar:RegisterEvent("PET_BAR_HIDEGRID")
self:ApplyConfig() self:ApplyConfig()
self:SetupOptions() self:ToggleOptions()
self:RegisterEvent("UPDATE_BINDINGS", "ReassignBindings") self:RegisterEvent("UPDATE_BINDINGS", "ReassignBindings")
self:ReassignBindings() self:ReassignBindings()
@@ -70,7 +69,7 @@ function PetBarMod:OnDisable()
self.bar:UnregisterAllEvents() self.bar:UnregisterAllEvents()
self.bar:Hide() self.bar:Hide()
self:SetupOptions() self:ToggleOptions()
end end
local function onEnter(self, ...) local function onEnter(self, ...)
@@ -149,6 +148,12 @@ function PetBarMod:SetupOptions()
self.options.args = self:IsEnabled() and self.optionobject.table or self.disabledoptions self.options.args = self:IsEnabled() and self.optionobject.table or self.disabledoptions
end 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() function PetBarMod:ReassignBindings()
if not self.bar or not self.bar.buttons then return end if not self.bar or not self.bar.buttons then return end
ClearOverrideBindings(self.bar) ClearOverrideBindings(self.bar)
+8 -3
View File
@@ -22,7 +22,6 @@ local defaults = { profile = Bartender4:Merge({
function StanceBarMod:OnInitialize() function StanceBarMod:OnInitialize()
self.db = Bartender4.db:RegisterNamespace("StanceBar", defaults) self.db = Bartender4.db:RegisterNamespace("StanceBar", defaults)
self:SetEnabledState(self.db.profile.enabled) self:SetEnabledState(self.db.profile.enabled)
self:SetupOptions()
end end
function StanceBarMod:OnEnable() function StanceBarMod:OnEnable()
@@ -33,7 +32,7 @@ function StanceBarMod:OnEnable()
self.bar:ApplyConfig() self.bar:ApplyConfig()
self.bar:SetScript("OnEvent", StanceBar.OnEvent) self.bar:SetScript("OnEvent", StanceBar.OnEvent)
end end
self:SetupOptions() self:ToggleOptions()
self.bar:RegisterEvent("PLAYER_ENTERING_WORLD") self.bar:RegisterEvent("PLAYER_ENTERING_WORLD")
self.bar:RegisterEvent("UPDATE_SHAPESHIFT_FORMS") self.bar:RegisterEvent("UPDATE_SHAPESHIFT_FORMS")
self.bar:RegisterEvent("SPELL_UPDATE_COOLDOWN") self.bar:RegisterEvent("SPELL_UPDATE_COOLDOWN")
@@ -49,7 +48,7 @@ function StanceBarMod:OnDisable()
if not self.bar then return end if not self.bar then return end
self.bar:UnregisterAllEvents() self.bar:UnregisterAllEvents()
self.bar:Hide() self.bar:Hide()
self:SetupOptions() self:ToggleOptions()
end end
function StanceBarMod:SetupOptions() function StanceBarMod:SetupOptions()
@@ -92,6 +91,12 @@ function StanceBarMod:SetupOptions()
self.options.args = self:IsEnabled() and self.optionobject.table or self.disabledoptions self.options.args = self:IsEnabled() and self.optionobject.table or self.disabledoptions
end 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() function StanceBarMod:ApplyConfig()
if not self:IsEnabled() then return end if not self:IsEnabled() then return end
self.bar:ApplyConfig(self.db.profile) self.bar:ApplyConfig(self.db.profile)