comparison Modules/Options.lua @ 67:b6c30a5156f9

Rearranged options to go with their related features.
author Asa Ayers <Asa.Ayers@Gmail.com>
date Wed, 28 Jul 2010 07:35:14 -0700
parents 32d53abee666
children 2d65db19d3ce
comparison
equal deleted inserted replaced
66:b7bc0488f13b 67:b6c30a5156f9
1 local ItemAuditor = select(2, ...) 1 local ItemAuditor = select(2, ...)
2 local Options = ItemAuditor:NewModule("Options") 2 local Options = ItemAuditor:NewModule("Options")
3 3
4 local currentFaction = UnitFactionGroup("player") 4 local currentFaction = UnitFactionGroup("player")
5 local AHFactions = { currentFaction, 'Neutral' } 5 local AHFactions = { currentFaction, 'Neutral' }
6
7 -- TODO: Convert this to a text field.
8 local craftingThresholds = {5000, 10000, 50000}
9 local craftingThresholdsDisplay = {}
10
11 local currentVersion = "@project-version@"
12
13 for key, value in pairs(craftingThresholds) do
14 craftingThresholdsDisplay[key] = ItemAuditor:FormatMoney(value, '', true)
15 -- craftingThresholdsDisplay[key] = value
16 end
17 6
18 local windowIndex = nil 7 local windowIndex = nil
19 function Options.GetChatWindowList() 8 function Options.GetChatWindowList()
20 local windows = {} 9 local windows = {}
21 for i=1, NUM_CHAT_WINDOWS do 10 for i=1, NUM_CHAT_WINDOWS do
62 return selectedWindow 51 return selectedWindow
63 end 52 end
64 return DEFAULT_CHAT_FRAME 53 return DEFAULT_CHAT_FRAME
65 end 54 end
66 55
67 local optionsTable = {
68 handler = ItemAuditor,
69 name = "ItemAuditor "..currentVersion,
70 type = 'group',
71 args = {
72 prices = {
73 name = "Prices",
74 desc = "Control how your minimum price is calculated.",
75 type = 'group',
76 args = {
77 auction_house = {
78 type = "select",
79 name = "Auction House",
80 desc = "",
81 values = { currentFaction, 'Neutral' },
82 get = 'GetAH',
83 set = 'SetAH',
84 },
85 },
86 },
87
88
89 messages = {
90 name = "Messages",
91 desc = "Control which messages display in your chat window.",
92 type = 'group',
93 args = {
94
95 item_cost = {
96 type = "toggle",
97 name = "Item Cost",
98 desc = "Shows a message every time an item's cost changes",
99 get = function() return ItemAuditor.db.profile.messages.cost_updates end,
100 set = function(info, value) ItemAuditor.db.profile.messages.cost_updates = value end,
101 order = 0,
102 },
103 queue_skip = {
104 type = "toggle",
105 name = "Queue Skip",
106 desc = "Displays a message when an item is excluded from the queue.",
107 get = function() return ItemAuditor.db.profile.messages.queue_skip end,
108 set = function(info, value) ItemAuditor.db.profile.messages.queue_skip = value end,
109 disabled = 'IsQADisabled',
110 order = 1,
111 },
112 output = {
113 type = "select",
114 name = "Output",
115 desc = "",
116 values = Options.GetChatWindowList,
117 get = Options.GetChatWindowIndex,
118 set = Options.SetChatWindow,
119 },
120 },
121 },
122
123 qa_options = {
124 name = "QA Options",
125 desc = "Control how ItemAuditor integrates with QuickAuctions",
126 type = 'group',
127 disabled = function() return not ItemAuditor:IsQACompatible() end,
128 args = {
129 toggle_qa = {
130 type = "toggle",
131 name = "Enable Quick Auctions",
132 desc = "This will enable or disable Quick Auctions integration",
133 get = "IsQAEnabled",
134 set = "SetQAEnabled",
135 order = 0,
136 },
137 --[[
138 add_mail = {
139 type = "toggle",
140 name = "Add mail cost to QA Threshold",
141 get = "IsQAEnabled",
142 set = "SetQAEnabled",
143 order = 1,
144 },
145 ]]
146 auction_threshold = {
147 type = "range",
148 name = "Auction Threshold",
149 desc = "Don't create items that will make less than this amount of profit",
150 min = 0.0,
151 max = 1.0,
152 isPercent = true,
153 get = function() return ItemAuditor.db.char.auction_threshold end,
154 set = function(info, value)
155 ItemAuditor.db.char.auction_threshold = value
156 ItemAuditor:RefreshQAGroups()
157 end,
158 disabled = 'IsQADisabled',
159 order = 1,
160 },
161 refresh_qa = {
162 type = "execute",
163 name = "Refresh QA Thresholds",
164 desc = "Resets all Quick Auctions thresholds",
165 func = "RefreshQAGroups",
166 disabled = 'IsQADisabled',
167 order = 9,
168 },
169 }
170 },
171 crafting_options = {
172 name = "Crafting with Skillet",
173 desc = "/ia queue",
174 type = 'group',
175 disabled = function() return Skillet == nil end,
176 args = {
177 crafting_threshold = {
178 type = "select",
179 name = "Crafting Threshold",
180 desc = "Don't create items that will make less than this amount of profit",
181 values = craftingThresholdsDisplay,
182 get = function() return ItemAuditor.db.char.crafting_threshold end,
183 set = function(info, value) ItemAuditor.db.char.crafting_threshold = value end,
184 order = 11,
185 },
186 },
187 },
188 options = {
189 type = "execute",
190 name = "options",
191 desc = "Show Blizzard's options GUI",
192 func = "ShowOptionsGUI",
193 guiHidden = true,
194 },
195 queue = {
196 type = "execute",
197 name = "queue",
198 desc = "Queue",
199 func = "Queue",
200 guiHidden = true,
201 },
202 debug = {
203 type = "execute",
204 name = "debug",
205 desc = "Shows the debug frame",
206 func = function() ItemAuditor_DebugFrame:Show() end,
207 guiHidden = true,
208 },
209 invested = {
210 type = "execute",
211 name = "invested",
212 desc = "Shows what you have invested in",
213 func = "DisplayInvested",
214 guiHidden = false,
215 },
216 crafting = {
217 type = "execute",
218 name = "crafting",
219 desc = "<description goes here>",
220 func = "DisplayCrafting",
221 guiHidden = false,
222 },
223
224 suspend = {
225 type = "toggle",
226 name = "suspend",
227 desc = "Suspends ItemAuditor",
228 get = "IsEnabled",
229 set = "SetEnabled",
230 guiHidden = true,
231 },
232 },
233 }
234 56
235 function ItemAuditor:SetEnabled(info, enable) 57 function ItemAuditor:SetEnabled(info, enable)
236 self.db.profile.addon_enabled = enable 58 self.db.profile.addon_enabled = enable
237 if enable == self:IsEnabled() then 59 if enable == self:IsEnabled() then
238 -- do nothing 60 -- do nothing
241 self:Print('ItemAuditor is enabled.') 63 self:Print('ItemAuditor is enabled.')
242 else 64 else
243 self:Disable() 65 self:Disable()
244 self:Print('ItemAuditor is supended and will not watch for any events. Use "/ia suspend" to turn it back on.') 66 self:Print('ItemAuditor is supended and will not watch for any events. Use "/ia suspend" to turn it back on.')
245 end 67 end
246 end
247
248 function ItemAuditor:RegisterOptions()
249 self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("ItemAuditor", "ItemAuditor")
250 LibStub("AceConfig-3.0"):RegisterOptionsTable("ItemAuditor", optionsTable, {"ia"})
251 end 68 end
252 69
253 local function pairsByKeys (t, f) 70 local function pairsByKeys (t, f)
254 local a = {} 71 local a = {}
255 for n in pairs(t) do table.insert(a, n) end 72 for n in pairs(t) do table.insert(a, n) end
295 function ItemAuditor:ShowOptionsGUI() 112 function ItemAuditor:ShowOptionsGUI()
296 InterfaceOptionsFrame_OpenToCategory(self.optionsFrame) 113 InterfaceOptionsFrame_OpenToCategory(self.optionsFrame)
297 end 114 end
298 115
299 116
117 ItemAuditor.Options.args.messages = {
118 name = "Messages",
119 desc = "Control which messages display in your chat window.",
120 type = 'group',
121 args = {
122
123 item_cost = {
124 type = "toggle",
125 name = "Item Cost",
126 desc = "Shows a message every time an item's cost changes",
127 get = function() return ItemAuditor.db.profile.messages.cost_updates end,
128 set = function(info, value) ItemAuditor.db.profile.messages.cost_updates = value end,
129 order = 0,
130 },
131 queue_skip = {
132 type = "toggle",
133 name = "Queue Skip",
134 desc = "Displays a message when an item is excluded from the queue.",
135 get = function() return ItemAuditor.db.profile.messages.queue_skip end,
136 set = function(info, value) ItemAuditor.db.profile.messages.queue_skip = value end,
137 disabled = 'IsQADisabled',
138 order = 1,
139 },
140 output = {
141 type = "select",
142 name = "Output",
143 desc = "",
144 values = Options.GetChatWindowList,
145 get = Options.GetChatWindowIndex,
146 set = Options.SetChatWindow,
147 },
148 },
149 }
150
151 ItemAuditor.Options.args.prices = {
152 name = "Prices",
153 desc = "Control how your minimum price is calculated.",
154 type = 'group',
155 args = {
156 auction_house = {
157 type = "select",
158 name = "Auction House",
159 desc = "",
160 values = { currentFaction, 'Neutral' },
161 get = 'GetAH',
162 set = 'SetAH',
163 },
164 },
165 }