annotate modules/ReAction_ConfigUI/ReAction_ConfigUI.lua @ 46:aa0b7fd68462

rearranged options table initialization a little
author Flick <flickerstreak@gmail.com>
date Thu, 10 Apr 2008 23:27:58 +0000
parents 2232b8336903
children e12b736c23c3
rev   line source
flickerstreak@25 1 --[[
flickerstreak@25 2 ReAction Configuration UI module
flickerstreak@25 3
flickerstreak@33 4 Hooks into Blizzard Interface Options AddOns panel
flickerstreak@25 5 --]]
flickerstreak@25 6
flickerstreak@25 7 -- local imports
flickerstreak@25 8 local ReAction = ReAction
flickerstreak@25 9 local L = ReAction.L
flickerstreak@25 10
flickerstreak@25 11 -- module declaration
flickerstreak@25 12 local moduleID = "ConfigUI"
flickerstreak@33 13 local module = ReAction:NewModule( moduleID )
flickerstreak@25 14
flickerstreak@25 15 -- module methods
flickerstreak@25 16 function module:OnInitialize()
flickerstreak@30 17 ReAction.RegisterCallback(self,"OnOptionsRegistered")
flickerstreak@33 18 ReAction.RegisterCallback(self,"OnOptionsRefreshed")
flickerstreak@46 19 self:InitializeOptions()
flickerstreak@25 20 end
flickerstreak@25 21
flickerstreak@30 22 function module:OnOptionsRegistered(evt, context, module, opts)
flickerstreak@46 23 local c = self.configOptions.args[context]
flickerstreak@46 24 if c then
flickerstreak@30 25 for k, v in pairs(opts) do
flickerstreak@46 26 c.args[k] = v
flickerstreak@30 27 end
flickerstreak@30 28 end
flickerstreak@25 29 end
flickerstreak@25 30
flickerstreak@33 31 function module:OnOptionsRefreshed(evt)
flickerstreak@33 32 -- TODO: refresh options frame (just OpenConfig again?)
flickerstreak@25 33 end
flickerstreak@25 34
flickerstreak@25 35 function module:OpenConfig(bar)
flickerstreak@30 36 InterfaceOptionsFrame_OpenToFrame("ReAction")
flickerstreak@33 37 if bar then
flickerstreak@33 38 -- TODO: select the correct bar pane
flickerstreak@25 39 end
flickerstreak@25 40 end
flickerstreak@44 41
flickerstreak@46 42 function module:InitializeOptions()
flickerstreak@46 43 self.configOptions = {
flickerstreak@46 44 type = "group",
flickerstreak@46 45 childGroups = "tab",
flickerstreak@46 46 args = {
flickerstreak@46 47 global = {
flickerstreak@46 48 type = "group",
flickerstreak@46 49 name = L["Global Settings"],
flickerstreak@46 50 desc = L["Global configuration settings"],
flickerstreak@46 51 args = { },
flickerstreak@46 52 order = 1,
flickerstreak@46 53 },
flickerstreak@46 54 bar = {
flickerstreak@46 55 type = "group",
flickerstreak@46 56 name = L["Bar Config"],
flickerstreak@46 57 desc = L["Configuration settings for bars"],
flickerstreak@46 58 args = { },
flickerstreak@46 59 order = 2,
flickerstreak@46 60 },
flickerstreak@46 61 module = {
flickerstreak@46 62 type = "group",
flickerstreak@46 63 childGroups = "select",
flickerstreak@46 64 name = L["Module Settings"],
flickerstreak@46 65 desc = L["Configuration settings for each module"],
flickerstreak@46 66 args = { },
flickerstreak@46 67 order = -1,
flickerstreak@46 68 },
flickerstreak@46 69 },
flickerstreak@46 70 plugins = { }
flickerstreak@46 71 }
flickerstreak@46 72
flickerstreak@46 73 for c, tbl in pairs(self.configOptions.args) do
flickerstreak@46 74 for _, m in pairs(ReAction:GetOptions(c)) do
flickerstreak@46 75 for k, v in pairs(m) do
flickerstreak@46 76 tbl.args[k] = v
flickerstreak@46 77 end
flickerstreak@46 78 end
flickerstreak@46 79 end
flickerstreak@46 80
flickerstreak@46 81 self.configOptions.args.desc = {
flickerstreak@46 82 type = "description",
flickerstreak@46 83 name = L["Customizable replacement for Blizzard's Action Bars"],
flickerstreak@46 84 }
flickerstreak@46 85 self.configOptions.args.profile = LibStub("AceDBOptions-3.0"):GetOptionsTable(ReAction.db)
flickerstreak@46 86 self.configOptions.args.profile.order = -2
flickerstreak@46 87
flickerstreak@46 88 ReAction:RegisterOptions("module",self, {
flickerstreak@46 89 configUI = {
flickerstreak@46 90 type = "group",
flickerstreak@46 91 name = "Config UI",
flickerstreak@46 92 desc = "description",
flickerstreak@46 93 args = {
flickerstreak@46 94 foo = {
flickerstreak@46 95 type = "toggle",
flickerstreak@46 96 handler = self,
flickerstreak@46 97 name = "foo",
flickerstreak@46 98 desc = "description",
flickerstreak@46 99 get = function() return true end,
flickerstreak@46 100 set = function() end,
flickerstreak@46 101 }
flickerstreak@46 102 }
flickerstreak@46 103 },
flickerstreak@46 104 })
flickerstreak@46 105
flickerstreak@46 106 LibStub("AceConfigRegistry-3.0"):RegisterOptionsTable("ReAction",self.configOptions)
flickerstreak@46 107 self.frame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("ReAction", "ReAction")
flickerstreak@46 108 self.frame.obj:SetCallback("default", function() ReAction.db:ResetProfile() end)
flickerstreak@44 109 end
flickerstreak@44 110