changeset 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 77858d975df6
files Editor.lua Options.lua ReAction.lua ReAction.toc classes/Overlay.lua locale/enUS.lua modules/ConfigUI.lua modules/modules.xml
diffstat 8 files changed, 531 insertions(+), 570 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Editor.lua	Fri Oct 22 23:48:02 2010 +0000
@@ -0,0 +1,476 @@
+local addonName, addonTable = ...
+local ReAction = addonTable.ReAction
+local L = ReAction.L
+local _G = _G
+local wipe = wipe
+
+local AceConfigReg = LibStub("AceConfigRegistry-3.0")
+local AceConfigDialog = LibStub("AceConfigDialog-3.0")
+
+
+local pointTable = {
+  CENTER      = L["Center"], 
+  LEFT        = L["Left"],
+  RIGHT       = L["Right"],
+  TOP         = L["Top"],
+  BOTTOM      = L["Bottom"],
+  TOPLEFT     = L["Top Left"],
+  TOPRIGHT    = L["Top Right"],
+  BOTTOMLEFT  = L["Bottom Left"],
+  BOTTOMRIGHT = L["Bottom Right"],
+}
+
+local Editor = { }
+
+function Editor:New()
+  -- create new self
+  self = setmetatable( { }, { __index = self } )
+
+  self.barOptMap = setmetatable({},{__mode="v"})
+  self.tmp = { }
+  self.configID = "ReAction-Editor"
+
+  self.gui = LibStub("AceGUI-3.0"):Create("Frame")
+  
+  local frame = self.gui.frame
+  frame:SetClampedToScreen(true)
+  frame:Hide()
+
+  frame:SetScript("OnHide", 
+    function(...)
+      ReAction:SetConfigMode(false)
+    end)
+
+  self.options = {
+    type = "group",
+    name = L["Select Bar:"],
+    desc = "foo foo foo",
+    handler = self,
+    childGroups = "select",
+    args = {
+      launchConfig = {
+        type = "execute",
+        name = L["Global Config"],
+        desc = L["Opens ReAction global configuration settings panel"],
+        func = function()
+            if ReAction.db.profile.editorCloseOnLaunch then
+              self:Close()
+            end
+            ReAction:ShowOptions()
+          end,
+        order = 1
+      },
+      closeThis = {
+        type = "toggle",
+        name = L["Close Editor"],
+        desc = L["Close the Bar Editor when opening the ReAction global Interface Options"],
+        get  = function() return ReAction.db.profile.editorCloseOnLaunch end,
+        set  = function(info, val) ReAction.db.profile.editorCloseOnLaunch = val end,
+        order = 2,
+      },
+      hdr = {
+        type = "header",
+        name = "",
+        order = 3,
+      },
+      desc = {
+        type = "description",
+        name = L["Use the mouse to arrange and resize the bars on screen. Tooltips on bars indicate additional functionality."],
+        width = "double",
+        order = 4,
+      },
+      _new = {
+        type = "group",
+        name = L["New Bar..."],
+        order = 5,
+        args = { 
+          desc = {
+            type = "description",
+            name = L["Choose a name, type, and initial grid for your new action bar:"],
+            order = 1,
+          },
+          name = {
+            type = "input",
+            name = L["Bar Name"],
+            desc = L["Enter a name for your new action bar"],
+            get  = function() return self.tmp.barName or "" end,
+            set  = function(info, val) self.tmp.barName = val end,
+            order = 2,
+          },
+          type = {
+            type = "select",
+            name = L["Button Type"],
+            get  = function() return self.tmp.barType or ReAction:GetDefaultBarType() or "" end,
+            set  = function(info, val) 
+                     local c = ReAction:GetBarTypeConfig(val)
+                     self.tmp.barType = val 
+                     self.tmp.barSize = c.defaultButtonSize or self.tmp.barSize
+                     self.tmp.barRows = c.defaultBarRows or self.tmp.barRows
+                     self.tmp.barCols = c.defaultBarCols or self.tmp.barCols
+                     self.tmp.barSpacing = c.defaultBarSpacing or self.tmp.barSpacing
+                   end,
+            values = "GetBarTypes",
+            order = 3,
+          },
+          go = {
+            type = "execute",
+            name = L["Create Bar"],
+            func = "CreateBar",
+            order = 4,
+          },
+          grid = {
+            type = "group",
+            name = L["Button Grid"],
+            inline = true,
+            order = 5,
+            args = {
+              rows = {
+                type = "range",
+                name = L["Rows"],
+                get  = function() return self.tmp.barRows or 1 end,
+                set  = function(info, val) self.tmp.barRows = val end,
+                width = "full",
+                min = 1,
+                max = 32,
+                step = 1,
+                order = 2,
+              },
+              cols = {
+                type = "range",
+                name = L["Columns"],
+                get  = function() return self.tmp.barCols or 12 end,
+                set  = function(info, val) self.tmp.barCols = val end,
+                width = "full",
+                min = 1, 
+                max = 32,
+                step = 1,
+                order = 3,
+              },
+              sz = {
+                type = "range",
+                name = L["Size"],
+                get  = function() return self.tmp.barSize or 36 end,
+                set  = function(info, val) self.tmp.barSize = val end,
+                width = "full",
+                min = 10,
+                max = 72,
+                step = 1,
+                order = 4,
+              },
+              spacing = {
+                type = "range",
+                name = L["Spacing"],
+                get  = function() return self.tmp.barSpacing or 3 end,
+                set  = function(info, val) self.tmp.barSpacing = val end,
+                width = "full",
+                min = 0,
+                max = 24,
+                step = 1,
+                order = 5,
+              }
+            },
+          },
+        }
+      }
+    },
+  }
+
+  self.title = ("%s - %s"):format(L["ReAction"],L["Bar Editor"])
+  self.gui:SetTitle(self.title)
+
+  self.gui:SetCallback("OnClose", 
+    function() 
+      ReAction:SetConfigMode(false)
+    end )
+
+  AceConfigReg:RegisterOptionsTable(self.configID, self.options)
+  AceConfigDialog:SetDefaultSize(self.configID, 700, 540)
+
+  ReAction.RegisterCallback(self,"OnCreateBar")
+  ReAction.RegisterCallback(self,"OnDestroyBar")
+  ReAction.RegisterCallback(self,"OnEraseBar")
+  ReAction.RegisterCallback(self,"OnRenameBar")
+
+  for name, bar in ReAction:IterateBars() do
+    self:CreateBarTree(bar)
+  end
+
+  return self
+end
+
+
+function Editor:Open(bar, ...)
+  if bar then
+    AceConfigDialog:SelectGroup(self.configID, self.barOptMap[bar:GetName()], ...)
+  end
+  AceConfigDialog:Open(self.configID,self.gui)
+  self.gui:SetTitle(self.title)
+end
+
+function Editor:Close()
+  if self.gui then
+    print("closing...")
+    self.gui:ReleaseChildren()
+    self.gui:Hide()
+  end
+end
+
+function Editor:Refresh()
+  AceConfigReg:NotifyChange(self.configID)
+end
+
+function Editor:CreateBarTree(bar)
+  local name = bar:GetName()
+  -- AceConfig doesn't allow spaces, etc, in arg key names, and they must be
+  -- unique strings. So generate a unique key (it can be whatever) for the bar
+  local args = self.options.args
+  local key
+  local i = 1
+  repeat
+    key = ("bar%s"):format(i)
+    i = i+1
+  until args[key] == nil
+  self.barOptMap[name] = key
+  args[key] = { 
+    type = "group",
+    name = name,
+    childGroups = "tab",
+    order = i+100,
+    args = {
+      general = {
+        type = "group",
+        name = L["General"],
+        order = 1,
+        args = {
+          name = {
+            type = "input",
+            name = L["Rename Bar"],
+            get  = function() return bar:GetName() end,
+            set  = function(info, value) return ReAction:RenameBar(bar, value) end,
+            order = 1,
+          },
+          delete = {
+            type = "execute",
+            name = L["Delete Bar"],
+            desc = function() return bar:GetName() end,
+            confirm = true,
+            func = function() ReAction:EraseBar(bar) end,
+            order = 2
+          },
+          anchor = {
+            type = "group",
+            name = L["Anchor"],
+            inline = true,
+            args = {
+              frame = {
+                type = "input",
+                name = L["Frame"],
+                desc = L["The frame that the bar is anchored to"],
+                get  = function() local _, f = bar:GetAnchor(); return f end,
+                set  = function(info, val) bar:SetAnchor(nil,val) end,
+                validate = function(info, name) 
+                    if name then
+                      local f = ReAction:GetBar(name)
+                      if f then
+                        return true
+                      else
+                        f = _G[name]
+                        if f and type(f) == "table" and f.IsObjectType and f:IsObjectType("Frame") then
+                          local _, explicit = f:IsProtected()
+                          return explicit
+                        end
+                      end
+                    end
+                    return false
+                  end,
+                width = "double",
+                order = 1
+              },
+              point = {
+                type = "select",
+                name = L["Point"],
+                desc = L["Anchor point on the bar frame"],
+                style = "dropdown",
+                get  = function() return bar:GetAnchor() end,
+                set  = function(info, val) bar:SetAnchor(val) end,
+                values = pointTable,
+                order = 2,
+              },
+              relativePoint = {
+                type = "select",
+                name = L["Relative Point"],
+                desc = L["Anchor point on the target frame"],
+                style = "dropdown",
+                get  = function() local p,f,r = bar:GetAnchor(); return r end,
+                set  = function(info, val) bar:SetAnchor(nil,nil,val) end,
+                values = pointTable,
+                order = 3,
+              },
+              x = {
+                type = "input",
+                pattern = "\-?%d+",
+                name = L["X offset"],
+                get = function() local p,f,r,x = bar:GetAnchor(); return ("%d"):format(x) end,
+                set = function(info,val) bar:SetAnchor(nil,nil,nil,val) end,
+                order = 4
+              },
+              y = {
+                type = "input",
+                pattern = "\-?%d+",
+                name = L["Y offset"],
+                get = function() local p,f,r,x,y = bar:GetAnchor(); return ("%d"):format(y) end,
+                set = function(info,val) bar:SetAnchor(nil,nil,nil,nil,val) end,
+                order = 5
+              },
+            },
+            order = 3
+          },
+          alpha = {
+            type = "range",
+            name = L["Transparency"],
+            get  = function() return bar:GetAlpha() end,
+            set  = function(info, val) bar:SetAlpha(val) end,
+            min = 0, 
+            max = 1,
+            isPercent = true,
+            step = 0.01,
+            bigStep = 0.05,
+            order = 4,
+          },
+        },
+      },
+    }
+  }
+  self:RefreshBarOptions()
+end
+
+function Editor:RefreshBarOptions()
+  for name, key in pairs(self.barOptMap) do
+    local bar = ReAction:GetBar(name)
+    if bar and key and self.options.args[key] then
+      self.options.args[key].plugins = self:GenerateBarOptionsTable(bar)
+    end
+  end
+  AceConfigReg:NotifyChange(self.configID)
+end
+
+function Editor:OnCreateBar(evt, bar)
+  if not self.tmp.creating then
+    -- a bit of hack to work around OnCreateBar event handler ordering
+    self:CreateBarTree(bar)
+  end
+end
+
+function Editor:OnDestroyBar(evt, bar, name)
+  local key = self.barOptMap[name]
+  if key then
+    self.options.args[key] = nil
+  end
+  self:Refresh()
+end
+
+function Editor:OnEraseBar(evt, name)
+  local key = self.barOptMap[name]
+  self.barOptMap[name] = nil
+  if key then
+    self.options.args[key] = nil
+    self:Refresh()
+  end
+end
+
+function Editor:OnRenameBar(evt, bar, oldname, newname)
+  local key = self.barOptMap[oldname]
+  self.barOptMap[oldname], self.barOptMap[newname] = nil, key
+  if key then
+    self.options.args[key].name = newname
+    self:Refresh()
+  end
+end
+
+local _scratch = { }
+function Editor:GetBarTypes()
+  wipe(_scratch)
+  return ReAction:GetBarTypeOptions(_scratch)
+end
+
+function Editor:CreateBar()
+  if self.tmp.barName and self.tmp.barName ~= "" then
+    self.tmp.creating = true
+    local bar = ReAction:CreateBar(self.tmp.barName, self.tmp.barType or ReAction:GetDefaultBarType(), self.tmp.barRows, self.tmp.barCols, self.tmp.barSize, self.tmp.barSpacing)
+    if bar then
+      self:CreateBarTree(bar)
+      AceConfigDialog:SelectGroup(self.configID, self.barOptMap[self.tmp.barName])
+      self.tmp.barName = nil
+    end
+    self.tmp.creating = false
+  end
+end
+
+function Editor:GenerateBarOptionsTable( bar )
+  local opts = { }
+  if not ReAction.barOptionGenerators then
+    return
+  end
+
+  for module, func in pairs(ReAction.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
+
+
+
+---- Export to ReAction ----
+function ReAction:ShowEditor(bar, ...)
+  if InCombatLockdown() then
+    self:UserError(L["ReAction config mode disabled during combat."])
+  else
+    self.editor = self.editor or Editor:New()
+    self.editor:Open(bar, ...)
+    self:SetConfigMode(true)
+  end
+end
+
+function ReAction:CloseEditor()
+  if self.editor then
+    self.editor:Close()
+  end
+end
+
+function ReAction:RefreshEditor()
+  if self.editor then
+    self.editor:RefreshBarOptions()
+  end
+end
+
+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
+  self.barOptionGenerators = self.barOptionGenerators or { }
+  self.barOptionGenerators[module] = func
+
+  if self.editor then
+    self.editor:RefreshBarOptions()
+  end
+end
+
--- a/Options.lua	Fri Oct 22 16:03:04 2010 +0000
+++ b/Options.lua	Fri Oct 22 23:48:02 2010 +0000
@@ -128,8 +128,7 @@
     elseif option == "kb" then
       ReAction:SetKeybindMode(true)
     else
-      print(("ReAction %3.1f:"):format(ReAction.version))
-      print("Usage:")
+      print(("%s %s %s"):format(L["ReAction"], ReAction.version, L["Usage:"]))
       print("/rxn config")
       print("/rxn edit")
       print("/rxn lock")
--- 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
--- a/ReAction.toc	Fri Oct 22 16:03:04 2010 +0000
+++ b/ReAction.toc	Fri Oct 22 23:48:02 2010 +0000
@@ -15,6 +15,7 @@
 
 ReAction.lua
 Options.lua
+Editor.lua
 
 classes\classes.xml
 modules\modules.xml
--- a/classes/Overlay.lua	Fri Oct 22 16:03:04 2010 +0000
+++ b/classes/Overlay.lua	Fri Oct 22 23:48:02 2010 +0000
@@ -525,7 +525,7 @@
     f:SetScript("OnUpdate",nil)
     StoreSize(bar)
     ClampToButtons(bar)
-    ReAction:RefreshOptions()
+    ReAction:RefreshEditor()
   end
 
   local function CornerUpdate()
@@ -684,7 +684,7 @@
       end
 
       StoreExtents(bar)
-      ReAction:RefreshOptions()
+      ReAction:RefreshEditor()
       UpdateDragTooltip()
       UpdateAnchorDecoration()
     end
--- a/locale/enUS.lua	Fri Oct 22 16:03:04 2010 +0000
+++ b/locale/enUS.lua	Fri Oct 22 23:48:02 2010 +0000
@@ -25,6 +25,7 @@
 "Show the keybinding dialogue",
 "Skip profile keybind warning",
 "Don't show a warning about updating keybinds when switching profiles",
+"Usage:",
 "ReAction profile changed: check your keybinds, they may need to be updated.",
 "OK",
 "ReAction: can't configure in combat",
@@ -37,6 +38,48 @@
 "to unlock bars",
 "for keybind mode",
 
+-- Editor.lua
+"Center",
+"Left",
+"Right",
+"Top",
+"Bottom",
+"Top Left",  
+"Top Right",
+"Bottom Left",
+"Bottom Right",
+"Bar Editor",
+"Select Bar:",
+"Use the mouse to arrange and resize the bars on screen. Tooltips on bars indicate additional functionality.",
+"Global Config",
+"Opens ReAction global configuration settings panel",
+"Close Editor",
+"Close the Bar Editor when opening the ReAction global Interface Options",
+"New Bar...",
+"Choose a name, type, and initial grid for your new action bar:",
+"Bar Name",
+"Enter a name for your new action bar",
+"Button Type",
+"Button Grid",
+"Rows",
+"Columns",
+"Size",
+"Spacing",
+"Create Bar",
+"General",
+"Rename Bar",
+"Delete Bar",
+"Anchor",
+"Frame",
+"The frame that the bar is anchored to",
+"Point",
+"Anchor point on the bar frame",
+"Relative Point",
+"Anchor point on the target frame",
+"X offset",
+"Y offset",
+"Transparency",
+
 -- PetActionButton.lua
 "Pet action ID range is 1-10",
 
@@ -205,46 +248,6 @@
 "Show only when passenger",
 "Only show the button when riding as a passenger in a vehicle (no vehicle controls)",
 
--- ConfigUI
-"Center",
-"Left",
-"Right",
-"Top",
-"Bottom",
-"Top Left",  
-"Top Right",
-"Bottom Left",
-"Bottom Right",
-"Bar Editor",
-"Global Config",
-"Opens ReAction global configuration settings panel",
-"Close the Bar Editor when opening the ReAction global Interface Options",
-"New Bar...",
-"Choose a name, type, and initial grid for your new action bar:",
-"Bar Name",
-"Enter a name for your new action bar",
-"Button Type",
-"Create Bar",
-"General",
-"Rename Bar",
-"Delete Bar",
-"Anchor",
-"Frame",
-"The frame that the bar is anchored to",
-"Point",
-"Anchor point on the bar frame",
-"Relative Point",
-"Anchor point on the target frame",
-"X offset",
-"Y offset",
-"Transparency",
-"Button Grid",
-"Rows",
-"Columns",
-"Size",
-"Spacing",
-"Use the mouse to arrange and resize the bars on screen. Tooltips on bars indicate additional functionality.",
-
 
 }) do
   L[string] = true
--- a/modules/ConfigUI.lua	Fri Oct 22 16:03:04 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,466 +0,0 @@
---[[
-  ReAction Configuration UI module
-
-  Hooks into Blizzard Interface Options AddOns panel
---]]
-
--- local imports
-local addonName, addonTable = ...
-local ReAction = addonTable.ReAction
-local L = ReAction.L
-local _G = _G
-local AceConfigReg = LibStub("AceConfigRegistry-3.0")
-local AceConfigDialog = LibStub("AceConfigDialog-3.0")
-
--- module declaration
-local moduleID = "ConfigUI"
-local module = ReAction:NewModule( moduleID,
-  "AceEvent-3.0"
-)
-
--- module methods
-function module:OnInitialize()
-  self.db = ReAction.db:RegisterNamespace( moduleID,
-    { 
-      profile = {
-        editorCloseOnLaunch = true,
-      }
-    }
-  )
-
-  self:RegisterEvent("PLAYER_REGEN_DISABLED")
-  ReAction.RegisterCallback(self,"OnOptionsRegistered","OnOptionsRefreshed")
-  ReAction.RegisterCallback(self,"OnOptionsRefreshed")
-end
-
-function module:OnOptionsRefreshed(evt)
-  if self.editor then self.editor:Refresh() end
-end
-
-function module:PLAYER_REGEN_DISABLED()
-  if self.editor then
-    self.editor:Hide()
-  end
-end
-
-
-
-
-
-
--- Bar Editor --
-local function NewEditor()
-  -- private variables
-  local editorName = "ReAction-Editor"
-  local barOptMap = setmetatable({},{__mode="v"})
-  local tmp = { }
-  local pointTable = {
-    CENTER      = L["Center"], 
-    LEFT        = L["Left"],
-    RIGHT       = L["Right"],
-    TOP         = L["Top"],
-    BOTTOM      = L["Bottom"],
-    TOPLEFT     = L["Top Left"],
-    TOPRIGHT    = L["Top Right"],
-    BOTTOMLEFT  = L["Bottom Left"],
-    BOTTOMRIGHT = L["Bottom Right"],
-  }
-
-
-  local editor = LibStub("AceGUI-3.0"):Create("Frame")
-  local frame = editor.frame
-  frame:SetClampedToScreen(true)
-  frame:Hide()
-  local old_OnUpdate = frame:GetScript("OnUpdate")
-  frame:SetScript("OnUpdate", function(dt)
-      if old_OnUpdate then
-        old_OnUpdate(dt)
-      end
-      if editor.selfClosePending then
-        editor:Hide()
-        editor.selfClosePending = false
-      end
-    end )
-  editor:SetCallback("OnClose", 
-    function() 
-      ReAction:SetConfigMode(false)
-    end )
-  AceConfigDialog:SetDefaultSize(editorName, 700, 540)
-  
-
-  local name = ("ReAction - %s"):format(L["Bar Editor"])
-  editor:SetTitle(name)
-  local options = {
-    type = "group",
-    name = name,
-    handler = editor,
-    childGroups = "tree",
-    args = {
-      desc = {
-        type = "description",
-        name = L["Use the mouse to arrange and resize the bars on screen. Tooltips on bars indicate additional functionality."],
-        order = 1
-      },
-      launchConfig = {
-        type = "execute",
-        name = L["Global Config"],
-        desc = L["Opens ReAction global configuration settings panel"],
-        func = function()
-            ReAction:ShowOptions()
-            -- you can't close a dialog in response to an options click, because the end of the 
-            -- handler for all the button events calls lib:Open()
-            -- So, schedule a close on the next OnUpdate
-            if module.db.profile.editorCloseOnLaunch then
-              editor.selfClosePending = true
-            end
-          end,
-        order = 2
-      },
-      closeThis = {
-        type = "toggle",
-        name = L["Close on Launch"],
-        desc = L["Close the Bar Editor when opening the ReAction global Interface Options"],
-        get  = function() return module.db.profile.editorCloseOnLaunch end,
-        set  = function(info, val) module.db.profile.editorCloseOnLaunch = val end,
-        order = 3,
-      },
-      new = {
-        type = "group",
-        name = L["New Bar..."],
-        order = 4,
-        args = { 
-          desc = {
-            type = "description",
-            name = L["Choose a name, type, and initial grid for your new action bar:"],
-            order = 1,
-          },
-          name = {
-            type = "input",
-            name = L["Bar Name"],
-            desc = L["Enter a name for your new action bar"],
-            get  = function() return tmp.barName or "" end,
-            set  = function(info, val) tmp.barName = val end,
-            order = 2,
-          },
-          type = {
-            type = "select",
-            name = L["Button Type"],
-            get  = function() return tmp.barType or ReAction:GetDefaultBarType() or "" end,
-            set  = function(info, val) 
-                     local c = ReAction:GetBarTypeConfig(val)
-                     tmp.barType = val 
-                     tmp.barSize = c.defaultButtonSize or tmp.barSize
-                     tmp.barRows = c.defaultBarRows or tmp.barRows
-                     tmp.barCols = c.defaultBarCols or tmp.barCols
-                     tmp.barSpacing = c.defaultBarSpacing or tmp.barSpacing
-                   end,
-            values = "GetBarTypes",
-            order = 3,
-          },
-          grid = {
-            type = "group",
-            name = L["Button Grid"],
-            inline = true,
-            args = {
-              hdr = {
-                type = "header",
-                name = L["Button Grid"],
-                order = 1,
-              },
-              rows = {
-                type = "range",
-                name = L["Rows"],
-                get  = function() return tmp.barRows or 1 end,
-                set  = function(info, val) tmp.barRows = val end,
-                width = "half",
-                min = 1,
-                max = 32,
-                step = 1,
-                order = 2,
-              },
-              cols = {
-                type = "range",
-                name = L["Columns"],
-                get  = function() return tmp.barCols or 12 end,
-                set  = function(info, val) tmp.barCols = val end,
-                width = "half",
-                min = 1, 
-                max = 32,
-                step = 1,
-                order = 3,
-              },
-              sz = {
-                type = "range",
-                name = L["Size"],
-                get  = function() return tmp.barSize or 36 end,
-                set  = function(info, val) tmp.barSize = val end,
-                width = "half",
-                min = 10,
-                max = 72,
-                step = 1,
-                order = 4,
-              },
-              spacing = {
-                type = "range",
-                name = L["Spacing"],
-                get  = function() return tmp.barSpacing or 3 end,
-                set  = function(info, val) tmp.barSpacing = val end,
-                width = "half",
-                min = 0,
-                max = 24,
-                step = 1,
-                order = 5,
-              }
-            },
-            order = 4
-          },
-          spacer = {
-            type = "header",
-            name = "",
-            width = "full",
-            order = -2
-          },
-          go = {
-            type = "execute",
-            name = L["Create Bar"],
-            func = "CreateBar",
-            order = -1,
-          }
-        }
-      }
-    }
-  }
-  AceConfigReg:RegisterOptionsTable(editorName, options)
-
-  function editor:Open(bar, ...)
-    if bar then
-      AceConfigDialog:SelectGroup(editorName, barOptMap[bar:GetName()], ...)
-    end
-    AceConfigDialog:Open(editorName,self)
-  end
-
-  function editor:Refresh()
-    AceConfigReg:NotifyChange(editorName)
-  end
-
-  function editor:CreateBarTree(bar)
-    local name = bar:GetName()
-    -- AceConfig doesn't allow spaces, etc, in arg key names, and they must be
-    -- unique strings. So generate a unique key (it can be whatever) for the bar
-    local args = options.args
-    local key
-    local i = 1
-    repeat
-      key = ("bar%s"):format(i)
-      i = i+1
-    until args[key] == nil
-    barOptMap[name] = key
-    args[key] = {
-      type = "group",
-      name = name,
-      childGroups = "tab",
-      args = {
-        general = {
-          type = "group",
-          name = L["General"],
-          order = 1,
-          args = {
-            name = {
-              type = "input",
-              name = L["Rename Bar"],
-              get  = function() return bar:GetName() end,
-              set  = function(info, value) return ReAction:RenameBar(bar, value) end,
-              order = 1,
-            },
-            delete = {
-              type = "execute",
-              name = L["Delete Bar"],
-              desc = function() return bar:GetName() end,
-              confirm = true,
-              func = function() ReAction:EraseBar(bar) end,
-              order = 2
-            },
-            anchor = {
-              type = "group",
-              name = L["Anchor"],
-              inline = true,
-              args = {
-                frame = {
-                  type = "input",
-                  name = L["Frame"],
-                  desc = L["The frame that the bar is anchored to"],
-                  get  = function() local _, f = bar:GetAnchor(); return f end,
-                  set  = function(info, val) bar:SetAnchor(nil,val) end,
-                  validate = function(info, name) 
-                      if name then
-                        local f = ReAction:GetBar(name)
-                        if f then
-                          return true
-                        else
-                          f = _G[name]
-                          if f and type(f) == "table" and f.IsObjectType and f:IsObjectType("Frame") then
-                            local _, explicit = f:IsProtected()
-                            return explicit
-                          end
-                        end
-                      end
-                      return false
-                    end,
-                  width = "double",
-                  order = 1
-                },
-                point = {
-                  type = "select",
-                  name = L["Point"],
-                  desc = L["Anchor point on the bar frame"],
-                  style = "dropdown",
-                  get  = function() return bar:GetAnchor() end,
-                  set  = function(info, val) bar:SetAnchor(val) end,
-                  values = pointTable,
-                  order = 2,
-                },
-                relativePoint = {
-                  type = "select",
-                  name = L["Relative Point"],
-                  desc = L["Anchor point on the target frame"],
-                  style = "dropdown",
-                  get  = function() local p,f,r = bar:GetAnchor(); return r end,
-                  set  = function(info, val) bar:SetAnchor(nil,nil,val) end,
-                  values = pointTable,
-                  order = 3,
-                },
-                x = {
-                  type = "input",
-                  pattern = "\-?%d+",
-                  name = L["X offset"],
-                  get = function() local p,f,r,x = bar:GetAnchor(); return ("%d"):format(x) end,
-                  set = function(info,val) bar:SetAnchor(nil,nil,nil,val) end,
-                  order = 4
-                },
-                y = {
-                  type = "input",
-                  pattern = "\-?%d+",
-                  name = L["Y offset"],
-                  get = function() local p,f,r,x,y = bar:GetAnchor(); return ("%d"):format(y) end,
-                  set = function(info,val) bar:SetAnchor(nil,nil,nil,nil,val) end,
-                  order = 5
-                },
-              },
-              order = 3
-            },
-            alpha = {
-              type = "range",
-              name = L["Transparency"],
-              get  = function() return bar:GetAlpha() end,
-              set  = function(info, val) bar:SetAlpha(val) end,
-              min = 0, 
-              max = 1,
-              isPercent = true,
-              step = 0.01,
-              bigStep = 0.05,
-              order = 4,
-            },
-          },
-        },
-      }
-    }
-    self:RefreshBarTree(bar)
-  end
-
-  function editor:RefreshBarTree(bar)
-    local key = barOptMap[bar:GetName()]
-    if key and options.args[key] then
-      options.args[key].plugins = ReAction:GenerateBarOptionsTable(bar)
-      AceConfigReg:NotifyChange(editorName)
-    end
-  end
-
-  function editor:OnCreateBar(evt, bar)
-    if not tmp.creating then
-      -- a bit of hack to work around OnCreateBar event handler ordering
-      self:CreateBarTree(bar)
-    end
-  end
-
-  function editor:OnDestroyBar(evt, bar, name)
-    local key = barOptMap[name]
-    if key then
-      options.args[key] = nil
-    end
-    self:Refresh()
-  end
-
-  function editor:OnEraseBar(evt, name)
-    local key = barOptMap[name]
-    barOptMap[name] = nil
-    if key then
-      options.args[key] = nil
-      self:Refresh()
-    end
-  end
-
-  function editor:OnRenameBar(evt, bar, oldname, newname)
-    local key = barOptMap[oldname]
-    barOptMap[oldname], barOptMap[newname] = nil, key
-    if key then
-      options.args[key].name = newname
-      self:Refresh()
-    end
-  end
-  
-  function editor:OnBarOptionGeneratorRegistered(evt)
-    for name in pairs(barOptMap) do
-      local bar = ReAction:GetBar(name)
-      if bar then
-        self:RefreshBarTree(bar)
-      end
-    end
-  end
-
-  local _scratch = { }
-  function editor:GetBarTypes()
-    for k,v in pairs(_scratch) do
-      _scratch[k] = nil
-    end
-    return ReAction:GetBarTypeOptions(_scratch)
-  end
-
-  function editor:CreateBar()
-    if tmp.barName and tmp.barName ~= "" then
-      tmp.creating = true
-      local bar = ReAction:CreateBar(tmp.barName, tmp.barType or ReAction:GetDefaultBarType(), tmp.barRows, tmp.barCols, tmp.barSize, tmp.barSpacing)
-      if bar then
-        self:CreateBarTree(bar)
-        AceConfigDialog:SelectGroup(editorName, barOptMap[tmp.barName])
-        tmp.barName = nil
-      end
-      tmp.creating = false
-    end
-  end
-
-  ReAction.RegisterCallback(editor,"OnCreateBar")
-  ReAction.RegisterCallback(editor,"OnDestroyBar")
-  ReAction.RegisterCallback(editor,"OnEraseBar")
-  ReAction.RegisterCallback(editor,"OnRenameBar")
-  ReAction.RegisterCallback(editor,"OnBarOptionGeneratorRegistered")
-
-  for name, bar in ReAction:IterateBars() do
-    editor:CreateBarTree(bar)
-  end
-
-  return editor
-end
-
-
-function module:LaunchBarEditor(bar, ...)
-  if InCombatLockdown() then
-    ReAction:UserError(L["ReAction config mode disabled during combat."])
-  else
-    if not self.editor then
-      self.editor = NewEditor()
-    end
-    self.editor:Open(bar, ...)
-    ReAction:SetConfigMode(true)
-  end
-end
-
--- a/modules/modules.xml	Fri Oct 22 16:03:04 2010 +0000
+++ b/modules/modules.xml	Fri Oct 22 23:48:02 2010 +0000
@@ -2,7 +2,6 @@
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://www.blizzard.com/wow/ui/..\FrameXML\UI.xsd">
 
-<Script file="ConfigUI.lua"/>
 <Script file="State.lua"/>
 <Script file="LBF.lua"/>
 <Script file="HideBlizzard.lua"/>