Mercurial > wow > reaction
diff ReAction.lua @ 185:2e7a322e0195
move ConfigUI module to Editor non-module, make it more self-contained
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Fri, 22 Oct 2010 23:48:02 +0000 |
parents | 1ee86bbb05a0 |
children | 55af1ebbec65 |
line wrap: on
line diff
--- a/ReAction.lua Fri Oct 22 16:03:04 2010 +0000 +++ b/ReAction.lua Fri Oct 22 23:48:02 2010 +0000 @@ -4,7 +4,6 @@ The ReAction core manages several collections: - modules (via AceAddon) - bars - - bar options - bar-type constructors and publishes events when those collections change. It also implements a couple properties @@ -19,17 +18,15 @@ "OnEraseBar" (bar, name) : before a bar config is removed from the profile db "OnRenameBar" (bar, oldname, newname) : after a bar is renamed "OnRefreshBar" (bar, name) : after a bar's state has been updated - "OnOptionsRefreshed" () : after the global options tree is refreshed "OnConfigModeChanged" (mode) : after the config mode is changed - "OnBarOptionGeneratorRegistered" (module, function) : after an options generator function is registered ReAction is also an AceAddon-3.0 and contains an AceDB-3.0, which in turn publish more events. ]]-- -local addonName, addonTable = ... -local ReAction = LibStub("AceAddon-3.0"):NewAddon( addonName, +local _, addonTable = ... +local ReAction = LibStub("AceAddon-3.0"):NewAddon( "ReAction", "AceEvent-3.0" ) -ReAction.version = GetAddOnMetadata(addonName,"Version") +ReAction.version = "1.0" addonTable.ReAction = ReAction ------ LIBRARIES ------ @@ -44,10 +41,9 @@ local private = { } local bars = {} local defaultBarConfig = {} -local barOptionGenerators = { } -local SelectBar, DestroyBar, InitializeBars, TearDownBars, DeepCopy, CallModuleMethod +local SelectBar, DestroyBar, InitializeBars, TearDownBars, DeepCopy do local pcall = pcall local geterrorhandler = geterrorhandler @@ -115,15 +111,6 @@ return r end - function CallModuleMethod(modulename, method, ...) - local m = self:GetModule(modulename,true) - if m then - if type(m) == "table" and type(m[method]) == "function" then - m[method](m,...) - end - end - end - end @@ -135,6 +122,7 @@ bars = { }, defaultBar = { }, closeOptionsOnEditorLaunch = true, + editorCloseOnLaunch = true, } }, true -- use global 'Default' (locale-specific) @@ -160,6 +148,7 @@ self:UserError(L["ReAction config mode disabled during combat."]) self:SetConfigMode(false) self:SetKeybindMode(false) + self:CloseEditor() end end @@ -289,7 +278,7 @@ if isDefaultChoice then private.defaultBarConfigChoice = name end - self:RefreshOptions() + self:RefreshEditor() end function ReAction:UnregisterBarType( name ) @@ -297,7 +286,7 @@ if private.defaultBarConfigChoice == name then private.defaultBarConfigChoice = nil end - self:RefreshOptions() + self:RefreshEditor() end function ReAction:IterateBarTypes() @@ -322,56 +311,6 @@ return private.defaultBarConfigChoice end -function ReAction:RefreshOptions() - callbacks:Fire("OnOptionsRefreshed") -end - --- --- In addition to global options, options tables --- must be generated dynamically for each bar. --- --- 'func' should be a function or a method string. --- The function or method will be passed the bar as its parameter. --- (methods will of course get the module as the first 'self' parameter) --- --- A generator can be unregistered by passing a nil func. --- -function ReAction:RegisterBarOptionGenerator( module, func ) - if not module or type(module) ~= "table" then -- doesn't need to be a proper module, strictly - error("ReAction:RegisterBarOptionGenerator() : Invalid module") - end - if type(func) == "string" then - if not module[func] then - error(("ReAction:RegisterBarOptionGenerator() : Invalid method '%s'"):format(func)) - end - elseif func and type(func) ~= "function" then - error("ReAction:RegisterBarOptionGenerator() : Invalid function") - end - barOptionGenerators[module] = func - callbacks:Fire("OnBarOptionGeneratorRegistered", module, func) -end - --- builds a table suitable for use as an AceConfig3 group 'plugins' sub-table -function ReAction:GenerateBarOptionsTable( bar ) - local opts = { } - for module, func in pairs(barOptionGenerators) do - local success, r - if type(func) == "string" then - success, r = pcall(module[func], module, bar) - else - success, r = pcall(func, bar) - end - if success then - if r then - opts[module:GetName()] = { [module:GetName()] = r } - end - else - geterrorhandler()(r) - end - end - return opts -end - function ReAction:SetConfigMode( mode ) if mode ~= private.configMode then private.configMode = mode @@ -383,10 +322,6 @@ return private.configMode end -function ReAction:ShowEditor(bar, ...) - CallModuleMethod("ConfigUI","LaunchBarEditor",bar, ...) -end - function ReAction:SetKeybindMode( mode ) if mode ~= private.kbMode then if mode then