annotate Modules/Options.lua @ 9:374dd1a90d02
Changed the way things are stored so that items known only by name, usually from AH mail, will be stored by their name, but will get converted if the link is discovered through a tooltip. This version is funcioning again
author |
Asa Ayers <Asa.Ayers@Gmail.com> |
date |
Fri, 25 Jun 2010 01:17:58 -0700 |
parents |
bbba2fae0f69 |
children |
6a6296dd249f |
rev |
line source |
Asa@3
|
1 local addonName, addonTable = ...;
|
Asa@3
|
2 local addon = _G[addonName]
|
Asa@3
|
3
|
Asa@3
|
4 local utils = addonTable.utils
|
Asa@3
|
5
|
Asa@3
|
6 local options = {
|
Asa@3
|
7 name = "ItemAuditor",
|
Asa@3
|
8 handler = addon,
|
Asa@3
|
9 type = 'group',
|
Asa@3
|
10 args = {
|
Asa@3
|
11 debug = {
|
Asa@3
|
12 type = "toggle",
|
Asa@3
|
13 name = "Debug",
|
Asa@3
|
14 desc = "Toggles debug messages in chat",
|
Asa@3
|
15 handler = utils,
|
Asa@3
|
16 get = "GetDebug",
|
Asa@3
|
17 set = "SetDebug"
|
Asa@3
|
18 },
|
Asa@3
|
19 dump = {
|
Asa@3
|
20 type = "execute",
|
Asa@3
|
21 name = "dump",
|
Asa@3
|
22 desc = "dumps IA database",
|
Asa@3
|
23 func = "DumpInfo",
|
Asa@3
|
24 },
|
Asa@3
|
25 options = {
|
Asa@3
|
26 type = "execute",
|
Asa@3
|
27 name = "options",
|
Asa@3
|
28 desc = "Show Blizzard's options GUI",
|
Asa@3
|
29 func = "ShowOptionsGUI",
|
Asa@3
|
30 guiHidden = true,
|
Asa@3
|
31 },
|
Asa@3
|
32 },
|
Asa@3
|
33 }
|
Asa@3
|
34
|
Asa@3
|
35 function addon:RegisterOptions()
|
Asa@3
|
36 self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("ItemAuditor", "ItemAuditor")
|
Asa@3
|
37 LibStub("AceConfig-3.0"):RegisterOptionsTable("ItemAuditor", options, {"ia"})
|
Asa@3
|
38 end
|
Asa@3
|
39
|
Asa@7
|
40 local function pairsByKeys (t, f)
|
Asa@7
|
41 local a = {}
|
Asa@7
|
42 for n in pairs(t) do table.insert(a, n) end
|
Asa@7
|
43 table.sort(a, f)
|
Asa@7
|
44 local i = 0 -- iterator variable
|
Asa@7
|
45 local iter = function () -- iterator function
|
Asa@7
|
46 i = i + 1
|
Asa@7
|
47 if a[i] == nil then return nil
|
Asa@7
|
48 else return a[i], t[a[i]]
|
Asa@7
|
49 end
|
Asa@7
|
50 end
|
Asa@7
|
51 return iter
|
Asa@7
|
52 end
|
Asa@7
|
53
|
Asa@3
|
54 function addon:DumpInfo()
|
Asa@7
|
55 for itemName, value in pairsByKeys(self.db.factionrealm.item_account) do
|
Asa@7
|
56 self:Print(itemName .. ": " .. utils:FormatMoney(value))
|
Asa@7
|
57 end
|
Asa@3
|
58 end
|
Asa@3
|
59
|
Asa@7
|
60
|
Asa@3
|
61 function addon:ShowOptionsGUI()
|
Asa@3
|
62 InterfaceOptionsFrame_OpenToCategory(self.optionsFrame)
|
Asa@3
|
63 end
|
Asa@3
|
64
|
Asa@3
|
65 function addon:GetDebug(info)
|
Asa@3
|
66 return self.db.char.debug
|
Asa@3
|
67 end
|
Asa@3
|
68
|
Asa@3
|
69 function addon:SetDebug(info, input)
|
Asa@3
|
70 self.db.char.debug = input
|
Asa@3
|
71 local value = "off"
|
Asa@3
|
72 if input then
|
Asa@3
|
73 value = "on"
|
Asa@3
|
74 end
|
Asa@3
|
75 self:Print("Debugging is now: " .. value)
|
Asa@3
|
76 end
|