Mercurial > wow > reaction
diff modules/ReAction_ConfigUI/ReAction_ConfigUI.lua @ 30:0d95ce7a9ec2
- added Ace3 externs
- converted ReAction_ConfigUI to use blizzard interface addons panel via AceConfigDialog-3.0
- partially converted FuBar module to LibRock, deprecated it (going to remove it entirely later)
- cleaned up a couple other tidbits
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Wed, 02 Apr 2008 23:31:13 +0000 |
parents | 21bcaf8215ff |
children | c54c481ad0ed |
line wrap: on
line diff
--- a/modules/ReAction_ConfigUI/ReAction_ConfigUI.lua Wed Apr 02 18:22:02 2008 +0000 +++ b/modules/ReAction_ConfigUI/ReAction_ConfigUI.lua Wed Apr 02 23:31:13 2008 +0000 @@ -4,21 +4,18 @@ This modules creates and manages ReAction configuration elements, including: - - waterfall config menu system + - Interface Options panel - bar dragging and resizing control overlays - contextual menus Individual modules are responsible for populating these - configuration elements via the following functions: - - module:GetGlobalOptions( configModule ) - module:GetGlobalBarOptions( configModule ) - module:GetModuleOptions( configModule ) - module:GetBarConfigOptions( bar, configModule ) - module:GetBarMenuOptions( bar, configModule ) - - the ReAction_ConfigUI module is passed in as a parameter so that - option handlers can refresh the config UI. + configuration elements via ReAction:RegisterOptions(). The + valid values of 'context' are: + + - 'global' : added to the Global Settings tab + - 'module' : added to the Module Settings tab + - 'bar' : added to the Bar Settings tab + - 'barMenu' : shown on the bar contextual menu --]] @@ -26,71 +23,68 @@ local ReAction = ReAction local L = ReAction.L local _G = _G -local Waterfall = AceLibrary("Waterfall-1.0") +local InCombatLockdown = InCombatLockdown + local Dewdrop = AceLibrary("Dewdrop-2.0") -local print = ReAction.print -local InCombatLockdown = InCombatLockdown -- module declaration local moduleID = "ConfigUI" local module = ReAction:NewModule( moduleID, "AceEvent-3.0" - -- mixins go here ) -module.globalOptions = { - type = "group", - args = { - unlock = { - type = "toggle", - handler = module, - name = L["unlock"], - guiName = L["Unlock Bars"], - desc = L["Unlock bars for dragging and resizing with the mouse"], - get = function() return module.configMode end, - set = "SetConfigMode", - disabled = InCombatLockdown, - order = 1 - }, - config = { - type = "execute", - handler = module, - name = L["config"], - guiName = L["Configure..."], - desc = L["Open the configuration dialogue"], - func = "OpenConfig", - disabled = InCombatLockdown, - wfHidden = true, -- don't show this in the waterfall config - order = 2 - }, - } -} - module.configOptions = { type = "group", + childGroups = "tab", args = { + desc = { + type = "description", + name = L["Customizable replacement for Blizzard's Action Bars"], + }, global = { type = "group", name = L["Global Settings"], desc = L["Global configuration settings"], - args = { }, + args = { + unlock = { + type = "toggle", + handler = module, + name = L["Unlock Bars"], + desc = L["Unlock bars for dragging and resizing with the mouse"], + get = function() return module.configMode end, + set = function(info, value) module:SetConfigMode(value) end, + disabled = InCombatLockdown, + order = 1 + }, + }, order = 1, }, module = { type = "group", + childGroups = "select", name = L["Module Settings"], desc = L["Configuration settings for each module"], - args = { }, - order = 2, + args = { + configUI = { + type = "group", + name = "Config UI", + desc = "description", + args = { + foo = { + type = "toggle", + handler = module, + name = "foo", + desc = "description", + get = function() return true end, + set = function() end, + } + } + }, + }, + order = -1, }, - bar = { - type = "group", - name = L["Bars"], - desc = L["Configuration settings for bars"], - args = { }, - order = 3, - }, - } + }, + plugins = { } } -- module methods @@ -100,30 +94,41 @@ profile = { } } ) + self:InitializeOptions() + LibStub("AceConfig-3.0"):RegisterOptionsTable("ReAction",self.configOptions) + LibStub("AceConfigDialog-3.0"):AddToBlizOptions("ReAction", "ReAction") + self:RegisterEvent("PLAYER_REGEN_DISABLED") end -function module:OnEnable() - self:RegisterEvent("PLAYER_REGEN_DISABLED") - Waterfall:Register("ReAction", - "aceOptions", self.configOptions, - "treeLevels", nil, -- infinite - "colorR", 0.8, - "colorG", 0.65, - "colorB", 0, - "defaultPane", "global" ) +function module:InitializeOptions() + for _, m in pairs(ReAction:GetOptions("global")) do + for k, v in pairs(m) do + self.configOptions.args.global.args[k] = v + end + end + ReAction.RegisterCallback(self,"OnOptionsRegistered") end -function module:OnDisable() - self:UnregisterEvent("PLAYER_REGEN_DISABLED") - self:SetConfigMode(false) - Waterfall:UnRegister("ReAction") +function module:OnOptionsRegistered(evt, context, module, opts) + if context == "global" then + for k, v in pairs(opts) do + self.configOptions.args.global.args[k] = v + end + elseif context == "module" then + for k, v in pairs(opts) do + self.configOptions.args.module.args[k] = v + end + elseif context == "bar" then + + elseif context == "barMenu" then + + end end function module:PLAYER_REGEN_DISABLED() if self.configMode == true then UIErrorsFrame:AddMessage(L["ReAction config mode disabled during combat."]) self:SetConfigMode(false) - Waterfall:Close("ReAction") end end @@ -149,107 +154,20 @@ end end -local function refreshWaterfall() - module:RefreshConfig() -end - -local function SafeCall(module, method, ...) +local function safecall(module, method, ...) if module and type(module[method]) == "function" then - return module[method](...) - end -end - -function module:RefreshOptions() - local opts = self.configOptions.args - - for _, m in ReAction:IterateModules() do - local o = SafeCall(m,"GetGlobalOptions",self) - if o then - for k, v in pairs(o) do - opts.global.args[k] = v - end - end - end - - for _, m in ReAction:IterateModules() do - local o = SafeCall(m,"GetGlobalBarOptions",self) - if o then - for k, v in pairs(o) do - opts.bar.args[k] = v - end - end - end - - for _, m in ReAction:IterateModules() do - local o = SafeCall(m,"GetModuleOptions",self) - if o then - for k, v in pairs(o) do - opts.module.args[k] = v - end - end - end - - local barOpts = opts.bar.args - for name, bar in pairs(ReAction.bars) do - if bar then - if barOpts[name] == nil then - barOpts[name] = { - type = "group", - name = name, - desc = name, - handler = bar, - args = { - delete = { - type = "execute", - name = L["Delete Bar"], - desc = L["Remove the bar from the current profile"], - func = function() ReAction:EraseBar(bar); self:RefreshConfig() end - }, - rename = { - type = "text", - name = L["Rename Bar"], - desc = L["Set a name for the bar"], - get = "GetName", - set = function(name) ReAction:RenameBar(bar,name); self:RefreshConfig() end - } - } - } - end - if bar.modConfigOpts == nil then - bar.modConfigOpts = { } - end - for _, m in ReAction:IterateModules() do - local o = SafeCall(m,"GetBarConfigOptions",bar,self) - if o then - for k, v in pairs(o) do - barOpts[name].args[k] = v - end - end - end - end - end - -- remove obsolete bar tables - for name, opt in pairs(barOpts) do - if opt.type == "group" and ReAction.bars[name] == nil then - barOpts[name] = nil - end + return module[method](method, ...) end end function module:OpenConfig(bar) - self:RefreshOptions() Dewdrop:Close() - Waterfall:Open("ReAction",bar and "bar."..bar:GetName()) -end - -function module:RefreshConfig() - self:RefreshOptions() - Waterfall:Refresh("ReAction") + InterfaceOptionsFrame_OpenToFrame("ReAction") end function module:ApplyToBar(bar) if self.configMode then - bar:ShowControls(true) + bar:ShowControls(self.configMode) end end @@ -262,10 +180,6 @@ end end -function module:GetGlobalOptions() - return self.globalOptions.args -end - @@ -547,9 +461,9 @@ -- add bar type and status information to name local name = bar.name for _, m in ReAction:IterateModules() do - local suffix = SafeCall(m,"GetBarNameModifier",bar) + local suffix = safecall(m,"GetBarNameModifier",bar) if suffix then - name = format("%s %s",name,suffix) + name = ("%s %s"):format(name,suffix) end end @@ -611,7 +525,7 @@ self.modMenuOpts = { } end for _, m in ReAction:IterateModules() do - local opts = SafeCall(m,"GetBarMenuOptions",self,module) + local opts = safecall(m,"GetBarMenuOptions",self,module) if opts then for k, v in pairs(opts) do self.menuOpts.args[k] = v