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@65
|
7 -- TODO: Convert this to a text field.
|
Asa@20
|
8 local craftingThresholds = {5000, 10000, 50000}
|
Asa@20
|
9 local craftingThresholdsDisplay = {}
|
Asa@20
|
10
|
Asa@57
|
11 local currentVersion = "@project-version@"
|
Asa@57
|
12
|
Asa@20
|
13 for key, value in pairs(craftingThresholds) do
|
Asa@63
|
14 craftingThresholdsDisplay[key] = ItemAuditor:FormatMoney(value, '', true)
|
Asa@20
|
15 -- craftingThresholdsDisplay[key] = value
|
Asa@20
|
16 end
|
Asa@20
|
17
|
Asa@55
|
18 local windowIndex = nil
|
Asa@65
|
19 function Options.GetChatWindowList()
|
Asa@55
|
20 local windows = {}
|
Asa@55
|
21 for i=1, NUM_CHAT_WINDOWS do
|
Asa@55
|
22 local name, _, _, _, _, _, shown, locked, docked = GetChatWindowInfo(i)
|
Asa@55
|
23 if (name ~= "") and (docked or shown) then
|
Asa@55
|
24 windows[i] = name
|
Asa@55
|
25 end
|
Asa@55
|
26 end
|
Asa@55
|
27 return windows
|
Asa@55
|
28 end
|
Asa@55
|
29
|
Asa@65
|
30 function Options:GetChatWindowIndex()
|
Asa@65
|
31 local cf = ItemAuditor.db.char.output_chat_frame
|
Asa@55
|
32 if not windowIndex then
|
Asa@55
|
33 for i=1, NUM_CHAT_WINDOWS do
|
Asa@55
|
34 local name, _, _, _, _, _, shown, locked, docked = GetChatWindowInfo(i)
|
Asa@55
|
35 if name ~= "" and cf ~= nil and cf == name then
|
Asa@65
|
36 Options.SetChatWindow(nil, i)
|
Asa@55
|
37 end
|
Asa@55
|
38 end
|
Asa@55
|
39 end
|
Asa@55
|
40 return windowIndex
|
Asa@55
|
41 end
|
Asa@55
|
42
|
Asa@55
|
43
|
Asa@55
|
44 local selectedWindow = nil
|
Asa@55
|
45
|
Asa@65
|
46 function Options.SetChatWindow(info, index)
|
Asa@55
|
47 windowIndex = index
|
Asa@55
|
48 local name = GetChatWindowInfo(windowIndex)
|
Asa@55
|
49
|
Asa@65
|
50 ItemAuditor.db.char.output_chat_frame = name
|
Asa@55
|
51 selectedWindow = nil
|
Asa@55
|
52 end
|
Asa@55
|
53
|
Asa@65
|
54 function Options.GetSelectedChatWindow()
|
Asa@55
|
55 if not selectedWindow then
|
Asa@65
|
56 local index = Options.GetChatWindowIndex()
|
Asa@56
|
57 if index then
|
Asa@56
|
58 selectedWindow = _G["ChatFrame"..index]
|
Asa@56
|
59 end
|
Asa@55
|
60 end
|
Asa@55
|
61 if (selectedWindow) then
|
Asa@55
|
62 return selectedWindow
|
Asa@55
|
63 end
|
Asa@55
|
64 return DEFAULT_CHAT_FRAME
|
Asa@55
|
65 end
|
Asa@55
|
66
|
Asa@63
|
67 local optionsTable = {
|
Asa@63
|
68 handler = ItemAuditor,
|
Asa@57
|
69 name = "ItemAuditor "..currentVersion,
|
Asa@3
|
70 type = 'group',
|
Asa@3
|
71 args = {
|
Asa@13
|
72 prices = {
|
Asa@13
|
73 name = "Prices",
|
Asa@13
|
74 desc = "Control how your minimum price is calculated.",
|
Asa@13
|
75 type = 'group',
|
Asa@13
|
76 args = {
|
Asa@13
|
77 auction_house = {
|
Asa@13
|
78 type = "select",
|
Asa@13
|
79 name = "Auction House",
|
Asa@13
|
80 desc = "",
|
Asa@13
|
81 values = { currentFaction, 'Neutral' },
|
Asa@13
|
82 get = 'GetAH',
|
Asa@13
|
83 set = 'SetAH',
|
Asa@13
|
84 },
|
Asa@13
|
85 },
|
Asa@3
|
86 },
|
Asa@13
|
87
|
Asa@13
|
88
|
Asa@13
|
89 messages = {
|
Asa@13
|
90 name = "Messages",
|
Asa@13
|
91 desc = "Control which messages display in your chat window.",
|
Asa@13
|
92 type = 'group',
|
Asa@13
|
93 args = {
|
Asa@20
|
94
|
Asa@20
|
95 item_cost = {
|
Asa@20
|
96 type = "toggle",
|
Asa@20
|
97 name = "Item Cost",
|
Asa@20
|
98 desc = "Shows a message every time an item's cost changes",
|
Asa@20
|
99 get = function() return ItemAuditor.db.profile.messages.cost_updates end,
|
Asa@20
|
100 set = function(info, value) ItemAuditor.db.profile.messages.cost_updates = value end,
|
Asa@20
|
101 order = 0,
|
Asa@20
|
102 },
|
Asa@20
|
103 queue_skip = {
|
Asa@20
|
104 type = "toggle",
|
Asa@20
|
105 name = "Queue Skip",
|
Asa@20
|
106 desc = "Displays a message when an item is excluded from the queue.",
|
Asa@20
|
107 get = function() return ItemAuditor.db.profile.messages.queue_skip end,
|
Asa@20
|
108 set = function(info, value) ItemAuditor.db.profile.messages.queue_skip = value end,
|
Asa@20
|
109 disabled = 'IsQADisabled',
|
Asa@20
|
110 order = 1,
|
Asa@20
|
111 },
|
Asa@55
|
112 output = {
|
Asa@55
|
113 type = "select",
|
Asa@55
|
114 name = "Output",
|
Asa@55
|
115 desc = "",
|
Asa@65
|
116 values = Options.GetChatWindowList,
|
Asa@65
|
117 get = Options.GetChatWindowIndex,
|
Asa@65
|
118 set = Options.SetChatWindow,
|
Asa@55
|
119 },
|
Asa@13
|
120 },
|
Asa@3
|
121 },
|
Asa@13
|
122
|
Asa@13
|
123 qa_options = {
|
Asa@13
|
124 name = "QA Options",
|
Asa@13
|
125 desc = "Control how ItemAuditor integrates with QuickAuctions",
|
Asa@13
|
126 type = 'group',
|
Asa@13
|
127 disabled = function() return not ItemAuditor:IsQACompatible() end,
|
Asa@13
|
128 args = {
|
Asa@13
|
129 toggle_qa = {
|
Asa@13
|
130 type = "toggle",
|
Asa@13
|
131 name = "Enable Quick Auctions",
|
Asa@13
|
132 desc = "This will enable or disable Quick Auctions integration",
|
Asa@13
|
133 get = "IsQAEnabled",
|
Asa@13
|
134 set = "SetQAEnabled",
|
Asa@13
|
135 order = 0,
|
Asa@13
|
136 },
|
Asa@13
|
137 --[[
|
Asa@13
|
138 add_mail = {
|
Asa@13
|
139 type = "toggle",
|
Asa@13
|
140 name = "Add mail cost to QA Threshold",
|
Asa@13
|
141 get = "IsQAEnabled",
|
Asa@13
|
142 set = "SetQAEnabled",
|
Asa@13
|
143 order = 1,
|
Asa@13
|
144 },
|
Asa@13
|
145 ]]
|
Asa@20
|
146 auction_threshold = {
|
Asa@20
|
147 type = "range",
|
Asa@20
|
148 name = "Auction Threshold",
|
Asa@20
|
149 desc = "Don't create items that will make less than this amount of profit",
|
Asa@20
|
150 min = 0.0,
|
Asa@20
|
151 max = 1.0,
|
Asa@20
|
152 isPercent = true,
|
Asa@20
|
153 get = function() return ItemAuditor.db.char.auction_threshold end,
|
Asa@21
|
154 set = function(info, value)
|
Asa@21
|
155 ItemAuditor.db.char.auction_threshold = value
|
Asa@21
|
156 ItemAuditor:RefreshQAGroups()
|
Asa@21
|
157 end,
|
Asa@20
|
158 disabled = 'IsQADisabled',
|
Asa@20
|
159 order = 1,
|
Asa@20
|
160 },
|
Asa@13
|
161 refresh_qa = {
|
Asa@13
|
162 type = "execute",
|
Asa@13
|
163 name = "Refresh QA Thresholds",
|
Asa@13
|
164 desc = "Resets all Quick Auctions thresholds",
|
Asa@13
|
165 func = "RefreshQAGroups",
|
Asa@13
|
166 disabled = 'IsQADisabled',
|
Asa@20
|
167 order = 9,
|
Asa@13
|
168 },
|
Asa@21
|
169 }
|
Asa@21
|
170 },
|
Asa@21
|
171 crafting_options = {
|
Asa@21
|
172 name = "Crafting with Skillet",
|
Asa@21
|
173 desc = "/ia queue",
|
Asa@21
|
174 type = 'group',
|
Asa@21
|
175 disabled = function() return Skillet == nil end,
|
Asa@21
|
176 args = {
|
Asa@20
|
177 crafting_threshold = {
|
Asa@20
|
178 type = "select",
|
Asa@20
|
179 name = "Crafting Threshold",
|
Asa@20
|
180 desc = "Don't create items that will make less than this amount of profit",
|
Asa@20
|
181 values = craftingThresholdsDisplay,
|
Asa@20
|
182 get = function() return ItemAuditor.db.char.crafting_threshold end,
|
Asa@20
|
183 set = function(info, value) ItemAuditor.db.char.crafting_threshold = value end,
|
Asa@20
|
184 order = 11,
|
Asa@20
|
185 },
|
Asa@21
|
186 },
|
Asa@12
|
187 },
|
Asa@3
|
188 options = {
|
Asa@3
|
189 type = "execute",
|
Asa@3
|
190 name = "options",
|
Asa@3
|
191 desc = "Show Blizzard's options GUI",
|
Asa@3
|
192 func = "ShowOptionsGUI",
|
Asa@3
|
193 guiHidden = true,
|
Asa@3
|
194 },
|
Asa@18
|
195 queue = {
|
Asa@18
|
196 type = "execute",
|
Asa@18
|
197 name = "queue",
|
Asa@18
|
198 desc = "Queue",
|
Asa@18
|
199 func = "Queue",
|
Asa@18
|
200 guiHidden = true,
|
Asa@18
|
201 },
|
Asa@22
|
202 debug = {
|
Asa@22
|
203 type = "execute",
|
Asa@22
|
204 name = "debug",
|
Asa@22
|
205 desc = "Shows the debug frame",
|
Asa@22
|
206 func = function() ItemAuditor_DebugFrame:Show() end,
|
Asa@22
|
207 guiHidden = true,
|
Asa@28
|
208 },
|
Asa@28
|
209 invested = {
|
Asa@28
|
210 type = "execute",
|
Asa@28
|
211 name = "invested",
|
Asa@28
|
212 desc = "Shows what you have invested in",
|
Asa@58
|
213 func = "DisplayInvested",
|
Asa@28
|
214 guiHidden = false,
|
Asa@28
|
215 },
|
Asa@59
|
216 crafting = {
|
Asa@59
|
217 type = "execute",
|
Asa@59
|
218 name = "crafting",
|
Asa@59
|
219 desc = "<description goes here>",
|
Asa@59
|
220 func = "DisplayCrafting",
|
Asa@59
|
221 guiHidden = false,
|
Asa@59
|
222 },
|
Asa@59
|
223
|
Asa@38
|
224 suspend = {
|
Asa@38
|
225 type = "toggle",
|
Asa@38
|
226 name = "suspend",
|
Asa@38
|
227 desc = "Suspends ItemAuditor",
|
Asa@38
|
228 get = "IsEnabled",
|
Asa@38
|
229 set = "SetEnabled",
|
Asa@38
|
230 guiHidden = true,
|
Asa@38
|
231 },
|
Asa@3
|
232 },
|
Asa@3
|
233 }
|
Asa@3
|
234
|
Asa@63
|
235 function ItemAuditor:SetEnabled(info, enable)
|
Asa@38
|
236 self.db.profile.addon_enabled = enable
|
Asa@38
|
237 if enable == self:IsEnabled() then
|
Asa@38
|
238 -- do nothing
|
Asa@38
|
239 elseif enable then
|
Asa@38
|
240 self:Enable()
|
Asa@38
|
241 self:Print('ItemAuditor is enabled.')
|
Asa@38
|
242 else
|
Asa@38
|
243 self:Disable()
|
Asa@38
|
244 self:Print('ItemAuditor is supended and will not watch for any events. Use "/ia suspend" to turn it back on.')
|
Asa@38
|
245 end
|
Asa@38
|
246 end
|
Asa@38
|
247
|
Asa@63
|
248 function ItemAuditor:RegisterOptions()
|
Asa@3
|
249 self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("ItemAuditor", "ItemAuditor")
|
Asa@63
|
250 LibStub("AceConfig-3.0"):RegisterOptionsTable("ItemAuditor", optionsTable, {"ia"})
|
Asa@3
|
251 end
|
Asa@3
|
252
|
Asa@7
|
253 local function pairsByKeys (t, f)
|
Asa@7
|
254 local a = {}
|
Asa@7
|
255 for n in pairs(t) do table.insert(a, n) end
|
Asa@7
|
256 table.sort(a, f)
|
Asa@7
|
257 local i = 0 -- iterator variable
|
Asa@7
|
258 local iter = function () -- iterator function
|
Asa@7
|
259 i = i + 1
|
Asa@7
|
260 if a[i] == nil then return nil
|
Asa@7
|
261 else return a[i], t[a[i]]
|
Asa@7
|
262 end
|
Asa@7
|
263 end
|
Asa@7
|
264 return iter
|
Asa@7
|
265 end
|
Asa@7
|
266
|
Asa@63
|
267 function ItemAuditor:GetCraftingThreshold()
|
Asa@20
|
268 local key = ItemAuditor.db.char.crafting_threshold
|
Asa@20
|
269 return craftingThresholds[key]
|
Asa@20
|
270 end
|
Asa@20
|
271
|
Asa@63
|
272 function ItemAuditor:GetAuctionThreshold()
|
Asa@20
|
273 return ItemAuditor.db.char.auction_threshold
|
Asa@20
|
274 end
|
Asa@20
|
275
|
Asa@63
|
276 function ItemAuditor:GetAH()
|
Asa@13
|
277 return ItemAuditor.db.char.ah
|
Asa@13
|
278 end
|
Asa@13
|
279
|
Asa@63
|
280 function ItemAuditor:SetAH(info, value)
|
Asa@13
|
281 ItemAuditor.db.char.ah = value
|
Asa@13
|
282 end
|
Asa@13
|
283
|
Asa@63
|
284 function ItemAuditor:GetAHCut()
|
Asa@13
|
285 if ItemAuditor.db.char.ah == 1 then
|
Asa@13
|
286 return 0.05
|
Asa@13
|
287 end
|
Asa@13
|
288 return 0.15
|
Asa@13
|
289 end
|
Asa@13
|
290
|
Asa@63
|
291 function ItemAuditor:GetAHFaction()
|
Asa@13
|
292 return AHFactions[ItemAuditor.db.char.ah]
|
Asa@13
|
293 end
|
Asa@13
|
294
|
Asa@63
|
295 function ItemAuditor:ShowOptionsGUI()
|
Asa@3
|
296 InterfaceOptionsFrame_OpenToCategory(self.optionsFrame)
|
Asa@3
|
297 end
|
Asa@3
|
298
|
Asa@3
|
299
|