comparison Modules/Options.lua @ 63:e7d287cc3b02

Replaced all instances of addon with ItemAuditor and I moved ItemAuditor out of the global namespace. The conversion was mostly a search/replace offering no new functionality. That will come in a later commit.
author Asa Ayers <Asa.Ayers@Gmail.com>
date Tue, 27 Jul 2010 17:58:33 -0700
parents 4ec321eb0dfe
children 32d53abee666
comparison
equal deleted inserted replaced
62:70dc84df13b3 63:e7d287cc3b02
1 local addonName, addonTable = ...; 1 local ItemAuditor = select(2, ...)
2 local addon = _G[addonName] 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 6
7 local craftingThresholds = {5000, 10000, 50000} 7 local craftingThresholds = {5000, 10000, 50000}
8 local craftingThresholdsDisplay = {} 8 local craftingThresholdsDisplay = {}
9 9
10 local currentVersion = "@project-version@" 10 local currentVersion = "@project-version@"
11 11
12 for key, value in pairs(craftingThresholds) do 12 for key, value in pairs(craftingThresholds) do
13 craftingThresholdsDisplay[key] = addon:FormatMoney(value, '', true) 13 craftingThresholdsDisplay[key] = ItemAuditor:FormatMoney(value, '', true)
14 -- craftingThresholdsDisplay[key] = value 14 -- craftingThresholdsDisplay[key] = value
15 end 15 end
16 16
17 local windowIndex = nil 17 local windowIndex = nil
18 function addon:GetChatWindowList() 18 function ItemAuditor:GetChatWindowList()
19 local windows = {} 19 local windows = {}
20 for i=1, NUM_CHAT_WINDOWS do 20 for i=1, NUM_CHAT_WINDOWS do
21 local name, _, _, _, _, _, shown, locked, docked = GetChatWindowInfo(i) 21 local name, _, _, _, _, _, shown, locked, docked = GetChatWindowInfo(i)
22 if (name ~= "") and (docked or shown) then 22 if (name ~= "") and (docked or shown) then
23 windows[i] = name 23 windows[i] = name
24 end 24 end
25 end 25 end
26 return windows 26 return windows
27 end 27 end
28 28
29 function addon:GetChatWindowIndex() 29 function ItemAuditor:GetChatWindowIndex()
30 local cf = self.db.char.output_chat_frame 30 local cf = self.db.char.output_chat_frame
31 if not windowIndex then 31 if not windowIndex then
32 for i=1, NUM_CHAT_WINDOWS do 32 for i=1, NUM_CHAT_WINDOWS do
33 local name, _, _, _, _, _, shown, locked, docked = GetChatWindowInfo(i) 33 local name, _, _, _, _, _, shown, locked, docked = GetChatWindowInfo(i)
34 if name ~= "" and cf ~= nil and cf == name then 34 if name ~= "" and cf ~= nil and cf == name then
40 end 40 end
41 41
42 42
43 local selectedWindow = nil 43 local selectedWindow = nil
44 44
45 function addon:SetChatWindow(info, index) 45 function ItemAuditor:SetChatWindow(info, index)
46 windowIndex = index 46 windowIndex = index
47 local name = GetChatWindowInfo(windowIndex) 47 local name = GetChatWindowInfo(windowIndex)
48 48
49 self.db.char.output_chat_frame = name 49 self.db.char.output_chat_frame = name
50 selectedWindow = nil 50 selectedWindow = nil
51 end 51 end
52 52
53 function addon:GetSelectedChatWindow() 53 function ItemAuditor:GetSelectedChatWindow()
54 if not selectedWindow then 54 if not selectedWindow then
55 local index = self:GetChatWindowIndex() 55 local index = self:GetChatWindowIndex()
56 if index then 56 if index then
57 selectedWindow = _G["ChatFrame"..index] 57 selectedWindow = _G["ChatFrame"..index]
58 end 58 end
61 return selectedWindow 61 return selectedWindow
62 end 62 end
63 return DEFAULT_CHAT_FRAME 63 return DEFAULT_CHAT_FRAME
64 end 64 end
65 65
66 local options = { 66 local optionsTable = {
67 handler = addon, 67 handler = ItemAuditor,
68 name = "ItemAuditor "..currentVersion, 68 name = "ItemAuditor "..currentVersion,
69 type = 'group', 69 type = 'group',
70 args = { 70 args = {
71 prices = { 71 prices = {
72 name = "Prices", 72 name = "Prices",
121 121
122 qa_options = { 122 qa_options = {
123 name = "QA Options", 123 name = "QA Options",
124 desc = "Control how ItemAuditor integrates with QuickAuctions", 124 desc = "Control how ItemAuditor integrates with QuickAuctions",
125 type = 'group', 125 type = 'group',
126 -- disabled = (not addon.QA_compatibile),
127 disabled = function() return not ItemAuditor:IsQACompatible() end, 126 disabled = function() return not ItemAuditor:IsQACompatible() end,
128 args = { 127 args = {
129 toggle_qa = { 128 toggle_qa = {
130 type = "toggle", 129 type = "toggle",
131 name = "Enable Quick Auctions", 130 name = "Enable Quick Auctions",
230 guiHidden = true, 229 guiHidden = true,
231 }, 230 },
232 }, 231 },
233 } 232 }
234 233
235 function addon:SetEnabled(info, enable) 234 function ItemAuditor:SetEnabled(info, enable)
236 self.db.profile.addon_enabled = enable 235 self.db.profile.addon_enabled = enable
237 if enable == self:IsEnabled() then 236 if enable == self:IsEnabled() then
238 -- do nothing 237 -- do nothing
239 elseif enable then 238 elseif enable then
240 self:Enable() 239 self:Enable()
243 self:Disable() 242 self:Disable()
244 self:Print('ItemAuditor is supended and will not watch for any events. Use "/ia suspend" to turn it back on.') 243 self:Print('ItemAuditor is supended and will not watch for any events. Use "/ia suspend" to turn it back on.')
245 end 244 end
246 end 245 end
247 246
248 function addon:RegisterOptions() 247 function ItemAuditor:RegisterOptions()
249 self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("ItemAuditor", "ItemAuditor") 248 self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("ItemAuditor", "ItemAuditor")
250 LibStub("AceConfig-3.0"):RegisterOptionsTable("ItemAuditor", options, {"ia"}) 249 LibStub("AceConfig-3.0"):RegisterOptionsTable("ItemAuditor", optionsTable, {"ia"})
251 end 250 end
252 251
253 local function pairsByKeys (t, f) 252 local function pairsByKeys (t, f)
254 local a = {} 253 local a = {}
255 for n in pairs(t) do table.insert(a, n) end 254 for n in pairs(t) do table.insert(a, n) end
262 end 261 end
263 end 262 end
264 return iter 263 return iter
265 end 264 end
266 265
267 function addon:GetCraftingThreshold() 266 function ItemAuditor:GetCraftingThreshold()
268 local key = ItemAuditor.db.char.crafting_threshold 267 local key = ItemAuditor.db.char.crafting_threshold
269 return craftingThresholds[key] 268 return craftingThresholds[key]
270 end 269 end
271 270
272 function addon:GetAuctionThreshold() 271 function ItemAuditor:GetAuctionThreshold()
273 return ItemAuditor.db.char.auction_threshold 272 return ItemAuditor.db.char.auction_threshold
274 end 273 end
275 274
276 function addon:GetAH() 275 function ItemAuditor:GetAH()
277 return ItemAuditor.db.char.ah 276 return ItemAuditor.db.char.ah
278 end 277 end
279 278
280 function addon:SetAH(info, value) 279 function ItemAuditor:SetAH(info, value)
281 ItemAuditor.db.char.ah = value 280 ItemAuditor.db.char.ah = value
282 end 281 end
283 282
284 function addon:GetAHCut() 283 function ItemAuditor:GetAHCut()
285 if ItemAuditor.db.char.ah == 1 then 284 if ItemAuditor.db.char.ah == 1 then
286 return 0.05 285 return 0.05
287 end 286 end
288 return 0.15 287 return 0.15
289 end 288 end
290 289
291 function addon:GetAHFaction() 290 function ItemAuditor:GetAHFaction()
292 return AHFactions[ItemAuditor.db.char.ah] 291 return AHFactions[ItemAuditor.db.char.ah]
293 end 292 end
294 293
295 function addon:ShowOptionsGUI() 294 function ItemAuditor:ShowOptionsGUI()
296 InterfaceOptionsFrame_OpenToCategory(self.optionsFrame) 295 InterfaceOptionsFrame_OpenToCategory(self.optionsFrame)
297 end 296 end
298 297
299 298