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@63
|
84 function ItemAuditor:GetCraftingThreshold()
|
Asa@20
|
85 local key = ItemAuditor.db.char.crafting_threshold
|
Asa@20
|
86 return craftingThresholds[key]
|
Asa@20
|
87 end
|
Asa@20
|
88
|
Asa@63
|
89 function ItemAuditor:GetAuctionThreshold()
|
Asa@20
|
90 return ItemAuditor.db.char.auction_threshold
|
Asa@20
|
91 end
|
Asa@20
|
92
|
Asa@63
|
93 function ItemAuditor:GetAH()
|
Asa@13
|
94 return ItemAuditor.db.char.ah
|
Asa@13
|
95 end
|
Asa@13
|
96
|
Asa@63
|
97 function ItemAuditor:SetAH(info, value)
|
Asa@13
|
98 ItemAuditor.db.char.ah = value
|
Asa@13
|
99 end
|
Asa@13
|
100
|
Asa@63
|
101 function ItemAuditor:GetAHCut()
|
Asa@13
|
102 if ItemAuditor.db.char.ah == 1 then
|
Asa@13
|
103 return 0.05
|
Asa@13
|
104 end
|
Asa@13
|
105 return 0.15
|
Asa@13
|
106 end
|
Asa@13
|
107
|
Asa@63
|
108 function ItemAuditor:GetAHFaction()
|
Asa@13
|
109 return AHFactions[ItemAuditor.db.char.ah]
|
Asa@13
|
110 end
|
Asa@13
|
111
|
Asa@63
|
112 function ItemAuditor:ShowOptionsGUI()
|
Asa@3
|
113 InterfaceOptionsFrame_OpenToCategory(self.optionsFrame)
|
Asa@3
|
114 end
|
Asa@3
|
115
|
Asa@3
|
116
|
Asa@67
|
117 ItemAuditor.Options.args.messages = {
|
Asa@67
|
118 name = "Messages",
|
Asa@67
|
119 desc = "Control which messages display in your chat window.",
|
Asa@67
|
120 type = 'group',
|
Asa@67
|
121 args = {
|
Asa@67
|
122
|
Asa@67
|
123 item_cost = {
|
Asa@67
|
124 type = "toggle",
|
Asa@67
|
125 name = "Item Cost",
|
Asa@67
|
126 desc = "Shows a message every time an item's cost changes",
|
Asa@67
|
127 get = function() return ItemAuditor.db.profile.messages.cost_updates end,
|
Asa@67
|
128 set = function(info, value) ItemAuditor.db.profile.messages.cost_updates = value end,
|
Asa@67
|
129 order = 0,
|
Asa@67
|
130 },
|
Asa@67
|
131 queue_skip = {
|
Asa@67
|
132 type = "toggle",
|
Asa@67
|
133 name = "Queue Skip",
|
Asa@67
|
134 desc = "Displays a message when an item is excluded from the queue.",
|
Asa@67
|
135 get = function() return ItemAuditor.db.profile.messages.queue_skip end,
|
Asa@67
|
136 set = function(info, value) ItemAuditor.db.profile.messages.queue_skip = value end,
|
Asa@67
|
137 disabled = 'IsQADisabled',
|
Asa@67
|
138 order = 1,
|
Asa@67
|
139 },
|
Asa@67
|
140 output = {
|
Asa@67
|
141 type = "select",
|
Asa@67
|
142 name = "Output",
|
Asa@67
|
143 desc = "",
|
Asa@67
|
144 values = Options.GetChatWindowList,
|
Asa@67
|
145 get = Options.GetChatWindowIndex,
|
Asa@67
|
146 set = Options.SetChatWindow,
|
Asa@67
|
147 },
|
Asa@67
|
148 },
|
Asa@67
|
149 }
|
Asa@67
|
150
|
Asa@67
|
151 ItemAuditor.Options.args.prices = {
|
Asa@67
|
152 name = "Prices",
|
Asa@67
|
153 desc = "Control how your minimum price is calculated.",
|
Asa@67
|
154 type = 'group',
|
Asa@67
|
155 args = {
|
Asa@67
|
156 auction_house = {
|
Asa@67
|
157 type = "select",
|
Asa@67
|
158 name = "Auction House",
|
Asa@67
|
159 desc = "",
|
Asa@67
|
160 values = { currentFaction, 'Neutral' },
|
Asa@67
|
161 get = 'GetAH',
|
Asa@67
|
162 set = 'SetAH',
|
Asa@67
|
163 },
|
Asa@67
|
164 },
|
Asa@67
|
165 } |