Asa@63
|
1 local ItemAuditor = select(2, ...)
|
Asa@63
|
2 local Options = ItemAuditor:NewModule("Options")
|
Asa@3
|
3
|
Asa@13
|
4 local currentFaction = UnitFactionGroup("player")
|
Asa@13
|
5 local AHFactions = { currentFaction, 'Neutral' }
|
Asa@13
|
6
|
Asa@55
|
7 local windowIndex = nil
|
Asa@65
|
8 function Options.GetChatWindowList()
|
Asa@55
|
9 local windows = {}
|
Asa@55
|
10 for i=1, NUM_CHAT_WINDOWS do
|
Asa@55
|
11 local name, _, _, _, _, _, shown, locked, docked = GetChatWindowInfo(i)
|
Asa@55
|
12 if (name ~= "") and (docked or shown) then
|
Asa@55
|
13 windows[i] = name
|
Asa@55
|
14 end
|
Asa@55
|
15 end
|
Asa@55
|
16 return windows
|
Asa@55
|
17 end
|
Asa@55
|
18
|
Asa@65
|
19 function Options:GetChatWindowIndex()
|
Asa@65
|
20 local cf = ItemAuditor.db.char.output_chat_frame
|
Asa@55
|
21 if not windowIndex then
|
Asa@55
|
22 for i=1, NUM_CHAT_WINDOWS do
|
Asa@55
|
23 local name, _, _, _, _, _, shown, locked, docked = GetChatWindowInfo(i)
|
Asa@55
|
24 if name ~= "" and cf ~= nil and cf == name then
|
Asa@65
|
25 Options.SetChatWindow(nil, i)
|
Asa@55
|
26 end
|
Asa@55
|
27 end
|
Asa@55
|
28 end
|
Asa@55
|
29 return windowIndex
|
Asa@55
|
30 end
|
Asa@55
|
31
|
Asa@55
|
32
|
Asa@55
|
33 local selectedWindow = nil
|
Asa@55
|
34
|
Asa@65
|
35 function Options.SetChatWindow(info, index)
|
Asa@55
|
36 windowIndex = index
|
Asa@55
|
37 local name = GetChatWindowInfo(windowIndex)
|
Asa@55
|
38
|
Asa@65
|
39 ItemAuditor.db.char.output_chat_frame = name
|
Asa@55
|
40 selectedWindow = nil
|
Asa@55
|
41 end
|
Asa@55
|
42
|
Asa@65
|
43 function Options.GetSelectedChatWindow()
|
Asa@55
|
44 if not selectedWindow then
|
Asa@65
|
45 local index = Options.GetChatWindowIndex()
|
Asa@56
|
46 if index then
|
Asa@56
|
47 selectedWindow = _G["ChatFrame"..index]
|
Asa@56
|
48 end
|
Asa@55
|
49 end
|
Asa@55
|
50 if (selectedWindow) then
|
Asa@55
|
51 return selectedWindow
|
Asa@55
|
52 end
|
Asa@55
|
53 return DEFAULT_CHAT_FRAME
|
Asa@55
|
54 end
|
Asa@55
|
55
|
Asa@3
|
56
|
Asa@63
|
57 function ItemAuditor:SetEnabled(info, enable)
|
Asa@38
|
58 self.db.profile.addon_enabled = enable
|
Asa@38
|
59 if enable == self:IsEnabled() then
|
Asa@38
|
60 -- do nothing
|
Asa@38
|
61 elseif enable then
|
Asa@38
|
62 self:Enable()
|
Asa@38
|
63 self:Print('ItemAuditor is enabled.')
|
Asa@38
|
64 else
|
Asa@38
|
65 self:Disable()
|
Asa@38
|
66 self:Print('ItemAuditor is supended and will not watch for any events. Use "/ia suspend" to turn it back on.')
|
Asa@38
|
67 end
|
Asa@38
|
68 end
|
Asa@38
|
69
|
Asa@7
|
70 local function pairsByKeys (t, f)
|
Asa@7
|
71 local a = {}
|
Asa@7
|
72 for n in pairs(t) do table.insert(a, n) end
|
Asa@7
|
73 table.sort(a, f)
|
Asa@7
|
74 local i = 0 -- iterator variable
|
Asa@7
|
75 local iter = function () -- iterator function
|
Asa@7
|
76 i = i + 1
|
Asa@7
|
77 if a[i] == nil then return nil
|
Asa@7
|
78 else return a[i], t[a[i]]
|
Asa@7
|
79 end
|
Asa@7
|
80 end
|
Asa@7
|
81 return iter
|
Asa@7
|
82 end
|
Asa@7
|
83
|
Asa@68
|
84
|
Asa@20
|
85
|
Asa@63
|
86 function ItemAuditor:GetAuctionThreshold()
|
Asa@20
|
87 return ItemAuditor.db.char.auction_threshold
|
Asa@20
|
88 end
|
Asa@20
|
89
|
Asa@63
|
90 function ItemAuditor:GetAH()
|
Asa@13
|
91 return ItemAuditor.db.char.ah
|
Asa@13
|
92 end
|
Asa@13
|
93
|
Asa@63
|
94 function ItemAuditor:SetAH(info, value)
|
Asa@13
|
95 ItemAuditor.db.char.ah = value
|
Asa@13
|
96 end
|
Asa@13
|
97
|
Asa@63
|
98 function ItemAuditor:GetAHCut()
|
Asa@13
|
99 if ItemAuditor.db.char.ah == 1 then
|
Asa@13
|
100 return 0.05
|
Asa@13
|
101 end
|
Asa@13
|
102 return 0.15
|
Asa@13
|
103 end
|
Asa@13
|
104
|
Asa@63
|
105 function ItemAuditor:GetAHFaction()
|
Asa@13
|
106 return AHFactions[ItemAuditor.db.char.ah]
|
Asa@13
|
107 end
|
Asa@13
|
108
|
Asa@63
|
109 function ItemAuditor:ShowOptionsGUI()
|
Asa@3
|
110 InterfaceOptionsFrame_OpenToCategory(self.optionsFrame)
|
Asa@3
|
111 end
|
Asa@3
|
112
|
Asa@3
|
113
|
Asa@67
|
114 ItemAuditor.Options.args.messages = {
|
Asa@67
|
115 name = "Messages",
|
Asa@67
|
116 desc = "Control which messages display in your chat window.",
|
Asa@67
|
117 type = 'group',
|
Asa@67
|
118 args = {
|
Asa@67
|
119
|
Asa@67
|
120 item_cost = {
|
Asa@67
|
121 type = "toggle",
|
Asa@67
|
122 name = "Item Cost",
|
Asa@67
|
123 desc = "Shows a message every time an item's cost changes",
|
Asa@67
|
124 get = function() return ItemAuditor.db.profile.messages.cost_updates end,
|
Asa@67
|
125 set = function(info, value) ItemAuditor.db.profile.messages.cost_updates = value end,
|
Asa@67
|
126 order = 0,
|
Asa@67
|
127 },
|
Asa@67
|
128 queue_skip = {
|
Asa@67
|
129 type = "toggle",
|
Asa@67
|
130 name = "Queue Skip",
|
Asa@67
|
131 desc = "Displays a message when an item is excluded from the queue.",
|
Asa@67
|
132 get = function() return ItemAuditor.db.profile.messages.queue_skip end,
|
Asa@67
|
133 set = function(info, value) ItemAuditor.db.profile.messages.queue_skip = value end,
|
Asa@67
|
134 disabled = 'IsQADisabled',
|
Asa@67
|
135 order = 1,
|
Asa@67
|
136 },
|
Asa@109
|
137 cod_warning = {
|
Asa@109
|
138 type = "toggle",
|
Asa@109
|
139 name = "COD Warning",
|
Asa@109
|
140 desc = "This will warn you to attach the correct COD amount if you are mailing items to another account",
|
Asa@109
|
141 get = function() return ItemAuditor.db.char.cod_warnings end,
|
Asa@109
|
142 set = function(info, value) ItemAuditor.db.char.cod_warnings = value end,
|
Asa@109
|
143 disabled = 'IsQADisabled',
|
Asa@109
|
144 order = 1,
|
Asa@109
|
145 },
|
Asa@67
|
146 output = {
|
Asa@67
|
147 type = "select",
|
Asa@67
|
148 name = "Output",
|
Asa@67
|
149 desc = "",
|
Asa@67
|
150 values = Options.GetChatWindowList,
|
Asa@67
|
151 get = Options.GetChatWindowIndex,
|
Asa@67
|
152 set = Options.SetChatWindow,
|
Asa@67
|
153 },
|
Asa@67
|
154 },
|
Asa@67
|
155 }
|
Asa@67
|
156
|
Asa@67
|
157 ItemAuditor.Options.args.prices = {
|
Asa@67
|
158 name = "Prices",
|
Asa@67
|
159 desc = "Control how your minimum price is calculated.",
|
Asa@67
|
160 type = 'group',
|
Asa@67
|
161 args = {
|
Asa@67
|
162 auction_house = {
|
Asa@67
|
163 type = "select",
|
Asa@67
|
164 name = "Auction House",
|
Asa@67
|
165 desc = "",
|
Asa@67
|
166 values = { currentFaction, 'Neutral' },
|
Asa@67
|
167 get = 'GetAH',
|
Asa@67
|
168 set = 'SetAH',
|
Asa@67
|
169 },
|
Asa@67
|
170 },
|
Asa@67
|
171 } |