comparison 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
comparison
equal deleted inserted replaced
45:38ee32135d86 46:aa0b7fd68462
10 10
11 -- module declaration 11 -- module declaration
12 local moduleID = "ConfigUI" 12 local moduleID = "ConfigUI"
13 local module = ReAction:NewModule( moduleID ) 13 local module = ReAction:NewModule( moduleID )
14 14
15 -- options table basic layer
16 module.configOptions = {
17 type = "group",
18 childGroups = "tab",
19 args = {
20 desc = {
21 type = "description",
22 name = L["Customizable replacement for Blizzard's Action Bars"],
23 },
24 global = {
25 type = "group",
26 name = L["Global Settings"],
27 desc = L["Global configuration settings"],
28 args = {
29 unlock = {
30 type = "toggle",
31 handler = module,
32 name = L["Unlock Bars"],
33 desc = L["Unlock bars for dragging and resizing with the mouse"],
34 get = function() return ReAction.configMode end,
35 set = function(info, value) ReAction:SetConfigMode(value) end,
36 disabled = InCombatLockdown,
37 order = 1
38 },
39 },
40 order = 1,
41 },
42 bar = {
43 type = "group",
44 name = L["Bar Settings"],
45 desc = L["Configuration settings for bars"],
46 childGroups = "select",
47 args = {
48 all = {
49 type = "group",
50 name = L["All Bars"],
51 desc = L["Settings applicable to all bars"],
52 args = {
53 foo = {
54 type = "toggle",
55 name = "foo",
56 desc = "description",
57 get = function() return true end,
58 set = function() end,
59 }
60 },
61 order = 1
62 }
63 },
64 order = 2
65 },
66 module = {
67 type = "group",
68 childGroups = "select",
69 name = L["Module Settings"],
70 desc = L["Configuration settings for each module"],
71 args = {
72 configUI = {
73 type = "group",
74 name = "Config UI",
75 desc = "description",
76 args = {
77 foo = {
78 type = "toggle",
79 handler = module,
80 name = "foo",
81 desc = "description",
82 get = function() return true end,
83 set = function() end,
84 }
85 }
86 },
87 },
88 order = -1,
89 },
90 },
91 plugins = { }
92 }
93
94 -- module methods 15 -- module methods
95 function module:OnInitialize() 16 function module:OnInitialize()
96 self.db = ReAction.db:RegisterNamespace( moduleID,
97 {
98 profile = { }
99 }
100 )
101
102 for _, m in pairs(ReAction:GetOptions("global")) do
103 for k, v in pairs(m) do
104 self.configOptions.args.global.args[k] = v
105 end
106 end
107
108 self.configOptions.args.profile = LibStub("AceDBOptions-3.0"):GetOptionsTable(ReAction.db)
109 self.configOptions.args.profile.order = -2
110
111 LibStub("AceConfigRegistry-3.0"):RegisterOptionsTable("ReAction",self.configOptions)
112 self.frame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("ReAction", "ReAction")
113 self.frame.obj.SetCallback(self,"default")
114
115 ReAction.RegisterCallback(self,"OnOptionsRegistered") 17 ReAction.RegisterCallback(self,"OnOptionsRegistered")
116 ReAction.RegisterCallback(self,"OnOptionsRefreshed") 18 ReAction.RegisterCallback(self,"OnOptionsRefreshed")
19 self:InitializeOptions()
117 end 20 end
118 21
119 function module:OnOptionsRegistered(evt, context, module, opts) 22 function module:OnOptionsRegistered(evt, context, module, opts)
120 if context == "global" then 23 local c = self.configOptions.args[context]
24 if c then
121 for k, v in pairs(opts) do 25 for k, v in pairs(opts) do
122 self.configOptions.args.global.args[k] = v 26 c.args[k] = v
123 end 27 end
124 elseif context == "module" then
125 for k, v in pairs(opts) do
126 self.configOptions.args.module.args[k] = v
127 end
128 elseif context == "bar" then
129
130 elseif context == "barMenu" then
131
132 end 28 end
133 end 29 end
134 30
135 function module:OnOptionsRefreshed(evt) 31 function module:OnOptionsRefreshed(evt)
136 -- TODO: refresh options frame (just OpenConfig again?) 32 -- TODO: refresh options frame (just OpenConfig again?)
141 if bar then 37 if bar then
142 -- TODO: select the correct bar pane 38 -- TODO: select the correct bar pane
143 end 39 end
144 end 40 end
145 41
146 function module:default() 42 function module:InitializeOptions()
147 -- called from the Interface Options panel, this returns the current profile to the default 43 self.configOptions = {
148 ReAction.db:ResetProfile() 44 type = "group",
45 childGroups = "tab",
46 args = {
47 global = {
48 type = "group",
49 name = L["Global Settings"],
50 desc = L["Global configuration settings"],
51 args = { },
52 order = 1,
53 },
54 bar = {
55 type = "group",
56 name = L["Bar Config"],
57 desc = L["Configuration settings for bars"],
58 args = { },
59 order = 2,
60 },
61 module = {
62 type = "group",
63 childGroups = "select",
64 name = L["Module Settings"],
65 desc = L["Configuration settings for each module"],
66 args = { },
67 order = -1,
68 },
69 },
70 plugins = { }
71 }
72
73 for c, tbl in pairs(self.configOptions.args) do
74 for _, m in pairs(ReAction:GetOptions(c)) do
75 for k, v in pairs(m) do
76 tbl.args[k] = v
77 end
78 end
79 end
80
81 self.configOptions.args.desc = {
82 type = "description",
83 name = L["Customizable replacement for Blizzard's Action Bars"],
84 }
85 self.configOptions.args.profile = LibStub("AceDBOptions-3.0"):GetOptionsTable(ReAction.db)
86 self.configOptions.args.profile.order = -2
87
88 ReAction:RegisterOptions("module",self, {
89 configUI = {
90 type = "group",
91 name = "Config UI",
92 desc = "description",
93 args = {
94 foo = {
95 type = "toggle",
96 handler = self,
97 name = "foo",
98 desc = "description",
99 get = function() return true end,
100 set = function() end,
101 }
102 }
103 },
104 })
105
106 LibStub("AceConfigRegistry-3.0"):RegisterOptionsTable("ReAction",self.configOptions)
107 self.frame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("ReAction", "ReAction")
108 self.frame.obj:SetCallback("default", function() ReAction.db:ResetProfile() end)
149 end 109 end
150 110