adam@0
|
1 local _, AskMrRobot = ...
|
yellowfive@11
|
2 local L = AskMrRobot.L;
|
adam@0
|
3
|
adam@0
|
4 -- initialize the ShoppingListTab class
|
adam@0
|
5 AskMrRobot.ShoppingListTab = AskMrRobot.inheritsFrom(AskMrRobot.Frame)
|
adam@0
|
6
|
adam@0
|
7 StaticPopupDialogs["SHOPPING_TAB_PLEASE_OPEN"] = {
|
yellowfive@11
|
8 text = L.AMR_SHOPPINGLISTTAB_OPEN_MAIL,
|
yellowfive@11
|
9 button1 = L.AMR_SHOPPINGLISTTAB_BUTTON_OK,
|
adam@0
|
10 timeout = 0,
|
adam@0
|
11 whileDead = true,
|
adam@0
|
12 hideOnEscape = true,
|
adam@0
|
13 preferredIndex = 3, -- avoid some UI taint, see http://www.wowace.com/announcements/how-to-avoid-some-ui-taint/
|
adam@0
|
14 }
|
adam@0
|
15
|
adam@0
|
16 function AskMrRobot.ShoppingListTab:new(parent)
|
adam@0
|
17
|
adam@0
|
18 local tab = AskMrRobot.Frame:new(nil, parent)
|
adam@0
|
19 setmetatable(tab, { __index = AskMrRobot.ShoppingListTab })
|
adam@0
|
20 tab:SetPoint("TOPLEFT")
|
adam@0
|
21 tab:SetPoint("BOTTOMRIGHT")
|
adam@0
|
22 tab:Hide()
|
adam@0
|
23 tab:RegisterEvent("AUCTION_HOUSE_CLOSED")
|
adam@0
|
24 tab:RegisterEvent("AUCTION_HOUSE_SHOW")
|
adam@0
|
25 tab:RegisterEvent("MAIL_SHOW")
|
adam@0
|
26 tab:RegisterEvent("MAIL_CLOSED")
|
adam@0
|
27
|
adam@0
|
28 tab.isAuctionHouseVisible = false
|
adam@0
|
29
|
adam@0
|
30 tab:SetScript("OnEvent", function(...)
|
adam@0
|
31 tab:OnEvent(...)
|
adam@0
|
32 end)
|
adam@0
|
33
|
adam@0
|
34 tab.shoppingListHeader = AskMrRobot.FontString:new(tab, nil, "ARTWORK", "GameFontNormalLarge")
|
adam@0
|
35 tab.shoppingListHeader:SetPoint("TOPLEFT", 0, -5)
|
yellowfive@11
|
36 tab.shoppingListHeader:SetText(L.AMR_SHOPPINGLISTTAB_TITLE)
|
adam@0
|
37
|
adam@0
|
38 tab.shoppingPanel = AskMrRobot.Frame:new(nil, tab)
|
adam@0
|
39 tab.shoppingPanel:SetPoint("TOPLEFT", tab.shoppingListHeader, "BOTTOMLEFT", 0, -10)
|
adam@0
|
40 tab.shoppingPanel:SetPoint("BOTTOMRIGHT", tab, "BOTTOMRIGHT", -20, 17)
|
adam@0
|
41
|
adam@0
|
42
|
adam@0
|
43 tab.sendButton = CreateFrame("Button", "AmrSendButton", tab.shoppingPanel, "UIPanelButtonTemplate")
|
yellowfive@11
|
44 tab.sendButton:SetText(L.AMR_SHOPPINGLISTTAB_BUTTON_SEND)
|
adam@0
|
45 tab.sendButton:SetPoint("BOTTOMLEFT", 0, 0)
|
adam@0
|
46 tab.sendButton:SetHeight(25)
|
adam@0
|
47 tab.sendButton:SetNormalFontObject("GameFontNormalLarge")
|
adam@0
|
48 tab.sendButton:SetHighlightFontObject("GameFontHighlightLarge")
|
adam@0
|
49 tab.sendButton:SetWidth(150)
|
adam@0
|
50 tab.sendButton:SetScript("OnClick", function()
|
adam@0
|
51 tab:Send()
|
adam@0
|
52 end)
|
adam@0
|
53
|
adam@0
|
54 tab.enchantMaterialsCheckbox = CreateFrame("CheckButton", "AmrEnchantMaterialsCheckbox", tab.shoppingPanel, "ChatConfigCheckButtonTemplate");
|
adam@0
|
55 tab.enchantMaterialsCheckbox:SetChecked(AmrSendSettings.SendEnchantMaterials)
|
adam@0
|
56 tab.enchantMaterialsCheckbox:SetScript("OnClick", function () AmrSendSettings.SendEnchantMaterials = tab.enchantMaterialsCheckbox:GetChecked() end)
|
adam@0
|
57 tab.enchantMaterialsCheckbox:SetPoint("TOPLEFT", tab.sendButton, "TOPLEFT", 0, 25)
|
adam@0
|
58 local text3 = getglobal(tab.enchantMaterialsCheckbox:GetName() .. 'Text')
|
adam@0
|
59 text3:SetFontObject("GameFontHighlightLarge")
|
yellowfive@11
|
60 text3:SetText(L.AMR_SHOPPINGLISTTAB_ENCHANT_MATERIALS)
|
adam@0
|
61 text3:SetWidth(150)
|
adam@0
|
62 text3:SetPoint("TOPLEFT", tab.enchantMaterialsCheckbox, "TOPRIGHT", 2, -4)
|
adam@0
|
63
|
adam@0
|
64
|
adam@0
|
65 tab.enchantsCheckbox = CreateFrame("CheckButton", "AmrEnchantsCheckbox", tab.shoppingPanel, "ChatConfigCheckButtonTemplate");
|
adam@0
|
66 tab.enchantsCheckbox:SetChecked(AmrSendSettings.SendEnchants)
|
adam@0
|
67 tab.enchantsCheckbox:SetScript("OnClick", function () AmrSendSettings.SendEnchants = tab.enchantsCheckbox:GetChecked() end)
|
adam@0
|
68 tab.enchantsCheckbox:SetPoint("TOPLEFT", tab.sendButton, "TOPLEFT", 0, 50)
|
adam@0
|
69 local text2 = getglobal(tab.enchantsCheckbox:GetName() .. 'Text')
|
adam@0
|
70 text2:SetFontObject("GameFontHighlightLarge")
|
yellowfive@11
|
71 text2:SetText(L.AMR_SHOPPINGLISTTAB_ENCHANTS)
|
adam@0
|
72 text2:SetWidth(150)
|
adam@0
|
73 text2:SetPoint("TOPLEFT", tab.enchantsCheckbox, "TOPRIGHT", 2, -4)
|
adam@0
|
74
|
adam@0
|
75
|
adam@0
|
76
|
adam@0
|
77 tab.gemsCheckbox = CreateFrame("CheckButton", "AmrGemsCheckbox", tab.shoppingPanel, "ChatConfigCheckButtonTemplate");
|
adam@0
|
78 tab.gemsCheckbox:SetPoint("TOPLEFT", tab.sendButton, "TOPLEFT", 0, 75)
|
adam@0
|
79 tab.gemsCheckbox:SetChecked(AmrSendSettings.SendGems)
|
adam@0
|
80 tab.gemsCheckbox:SetScript("OnClick", function () AmrSendSettings.SendGems = tab.gemsCheckbox:GetChecked() end)
|
adam@0
|
81 local text = getglobal(tab.gemsCheckbox:GetName() .. 'Text')
|
adam@0
|
82 text:SetFontObject("GameFontHighlightLarge")
|
yellowfive@11
|
83 text:SetText(L.AMR_SHOPPINGLISTTAB_GEMS)
|
adam@0
|
84 text:SetWidth(150)
|
adam@0
|
85 text:SetPoint("TOPLEFT", tab.gemsCheckbox, "TOPRIGHT", 2, -4)
|
adam@0
|
86
|
adam@0
|
87
|
adam@0
|
88 tab.sendMessage4 = AskMrRobot.FontString:new(tab.shoppingPanel, nil, "ARTWORK", "GameFontHighlightLarge")
|
yellowfive@11
|
89 tab.sendMessage4:SetText(L.AMR_SHOPPINGLISTTAB_INCLUDE)
|
adam@0
|
90 tab.sendMessage4:SetPoint("TOPLEFT", tab.gemsCheckbox, "TOPLEFT", 0, 20)
|
adam@0
|
91
|
adam@0
|
92
|
adam@0
|
93 tab.sendMessage3 = AskMrRobot.FontString:new(tab.shoppingPanel, nil, "ARTWORK", "GameFontHighlightLarge")
|
yellowfive@11
|
94 tab.sendMessage3:SetText(L.AMR_SHOPPINGLISTTAB_SEND_LIST_TO)
|
adam@0
|
95 tab.sendMessage3:SetPoint("TOPLEFT", tab.sendMessage4, "TOPLEFT", 0, 25)
|
adam@0
|
96
|
adam@0
|
97
|
adam@0
|
98 tab.sendMessage2 = AskMrRobot.FontString:new(tab.shoppingPanel, nil, "ARTWORK", "GameFontNormal")
|
adam@0
|
99 tab.sendMessage2:SetTextColor(.5,.5,.5)
|
yellowfive@11
|
100 tab.sendMessage2:SetText(L.AMR_SHOPPINGLISTTAB_WHISPER_CHANNEL)
|
adam@0
|
101 tab.sendMessage2:SetPoint("TOPLEFT", tab.sendMessage3, "TOPLEFT", 0, 25)
|
adam@0
|
102
|
adam@0
|
103
|
adam@0
|
104 tab.sendMessage1 = AskMrRobot.FontString:new(tab.shoppingPanel, nil, "ARTWORK", "GameFontNormalLarge")
|
adam@0
|
105 tab.sendMessage1:SetTextColor(0,1,0)
|
yellowfive@11
|
106 tab.sendMessage1:SetText(L.AMR_SHOPPINGLISTTAB_SEND_JEWELCRAFT_ENCHANTER)
|
adam@0
|
107 tab.sendMessage1:SetPoint("TOPLEFT", tab.sendMessage2, "TOPLEFT", 0, 25)
|
adam@0
|
108
|
adam@0
|
109
|
adam@0
|
110 tab.scrollFrame = CreateFrame("ScrollFrame", "AmrScrollFrame", tab.shoppingPanel, "UIPanelScrollFrameTemplate")
|
adam@0
|
111 tab.scrollFrame:SetPoint("TOPLEFT", 0, 0)
|
adam@0
|
112 tab.scrollFrame:SetPoint("RIGHT", -20, 0)
|
adam@0
|
113 tab.scrollFrame:SetPoint("BOTTOM", tab.sendMessage1, "TOP", 0, 10)
|
adam@0
|
114
|
adam@0
|
115 tab.scrollParent = AskMrRobot.Frame:new(nil, tab.shoppingPanel)
|
adam@0
|
116 tab.scrollParent:SetPoint("TOPLEFT", 0, 0)
|
adam@0
|
117 tab.scrollParent:SetWidth(tab:GetWidth() - 20)
|
adam@0
|
118 tab.scrollParent:SetHeight(500)
|
adam@0
|
119 tab.scrollFrame:SetScrollChild(tab.scrollParent)
|
adam@0
|
120
|
adam@0
|
121 -- magic to get the scrollbar to work with the scrollwheel...
|
adam@0
|
122 tab.scrollFrame:SetScript("OnMouseWheel", function(arg1, arg2)
|
adam@0
|
123 ScrollFrameTemplate_OnMouseWheel(arg1, arg2, arg1.ScrollBar)
|
adam@0
|
124 end)
|
adam@0
|
125
|
adam@0
|
126 tab.gemsHeader = AskMrRobot.FontString:new(tab.scrollParent, nil, "ARTWORK", "GameFontNormalLarge")
|
yellowfive@11
|
127 tab.gemsHeader:SetText(L.AMR_SHOPPINGLISTTAB_GEMS)
|
adam@0
|
128 tab.gemsHeader:SetPoint("TOPLEFT", tab.scrollParent, "TOPLEFT", 0, 0)
|
adam@0
|
129
|
adam@0
|
130 tab.gemsQuantityHeader = AskMrRobot.FontString:new(tab.scrollParent, nil, "ARTWORK", "GameFontNormalLarge")
|
yellowfive@11
|
131 tab.gemsQuantityHeader:SetText(L.AMR_SHOPPINGLISTTAB_TOTAL)
|
adam@0
|
132 tab.gemsQuantityHeader:SetPoint("TOPLEFT", tab.scrollParent, "TOPLEFT", 370, 0)
|
adam@0
|
133
|
adam@0
|
134 tab.enchantsHeader = AskMrRobot.FontString:new(tab.scrollParent, nil, "ARTWORK", "GameFontNormalLarge")
|
yellowfive@11
|
135 tab.enchantsHeader:SetText(L.AMR_SHOPPINGLISTTAB_ENCHANTS)
|
adam@0
|
136
|
adam@0
|
137 tab.enchantsQuantityHeader = AskMrRobot.FontString:new(tab.scrollParent, nil, "ARTWORK", "GameFontNormalLarge")
|
yellowfive@11
|
138 tab.enchantsQuantityHeader:SetText(L.AMR_SHOPPINGLISTTAB_TOTAL)
|
adam@0
|
139 tab.enchantsQuantityHeader:SetPoint("TOPLEFT", tab.enchantsHeader, "TOPLEFT", 370, 0)
|
adam@0
|
140
|
adam@0
|
141 tab.enchantMaterialsHeader = AskMrRobot.FontString:new(tab.scrollParent, nil, "ARTWORK", "GameFontNormalLarge")
|
yellowfive@11
|
142 tab.enchantMaterialsHeader:SetText(L.AMR_SHOPPINGLISTTAB_ENCHANT_MATERIALS)
|
adam@0
|
143
|
adam@0
|
144 tab.enchantMaterialsQuantityHeader = AskMrRobot.FontString:new(tab.scrollParent, nil, "ARTWORK", "GameFontNormalLarge")
|
yellowfive@11
|
145 tab.enchantMaterialsQuantityHeader:SetText(L.AMR_SHOPPINGLISTTAB_TOTAL)
|
adam@0
|
146 tab.enchantMaterialsQuantityHeader:SetPoint("TOPLEFT", tab.enchantMaterialsHeader, "TOPLEFT", 370, 0)
|
adam@0
|
147
|
adam@0
|
148 tab.stamp = AskMrRobot.RobotStamp:new(nil, tab)
|
adam@0
|
149 tab.stamp:Hide()
|
yellowfive@11
|
150 tab.stamp.bigText:SetText(L.AMR_SHOPPINGLISTTAB_DONE)
|
yellowfive@11
|
151 tab.stamp.smallText:SetText(L.AMR_SHOPPINGLISTTAB_A_ROBOTS_WISHLIST)
|
adam@0
|
152 tab.stamp:SetPoint("TOPLEFT", tab.shoppingListHeader, "BOTTOMLEFT", 2, -15)
|
adam@0
|
153 tab.stamp:SetPoint("RIGHT", tab, "RIGHT", -30, 0)
|
adam@0
|
154 tab.stamp:SetHeight(92)
|
adam@0
|
155
|
adam@0
|
156 tab.gemIcons = {}
|
adam@0
|
157 tab.gemLinks = {}
|
adam@0
|
158 tab.gemQuantity = {}
|
adam@0
|
159 tab.enchantIcons = {}
|
adam@0
|
160 tab.enchantLinks = {}
|
adam@0
|
161 tab.enchantQuantity = {}
|
adam@0
|
162 tab.enchantMaterialIcons = {}
|
adam@0
|
163 tab.enchantMaterialLinks = {}
|
adam@0
|
164 tab.enchantMaterialQuantity = {}
|
adam@0
|
165
|
adam@0
|
166 -- Create the dropdown, and configure its appearance
|
adam@0
|
167 tab.dropDown = CreateFrame("FRAME", "AmrSendType", tab.shoppingPanel, "UIDropDownMenuTemplate")
|
adam@0
|
168 tab.dropDown:SetPoint("TOPLEFT", tab.sendMessage3, "TOPRIGHT", 0, 5)
|
adam@0
|
169 UIDropDownMenu_SetWidth(tab.dropDown, 140)
|
adam@0
|
170 UIDropDownMenu_SetText(tab.dropDown, AmrSendSettings.SendToType)
|
adam@0
|
171
|
adam@0
|
172 local text = getglobal(tab.dropDown:GetName() .. 'Text')
|
adam@0
|
173 text:SetFontObject("GameFontHighlightLarge")
|
adam@0
|
174
|
adam@0
|
175 local AddButton = function(list, optionText)
|
adam@0
|
176 local info = UIDropDownMenu_CreateInfo()
|
adam@0
|
177 info.justifyH = "RIGHT"
|
adam@0
|
178 info.text = optionText
|
adam@0
|
179 info.checked = AmrSendSettings.SendToType == optionText
|
adam@0
|
180 info.arg1 = optionText
|
adam@0
|
181 info.func = list.SetValue
|
adam@0
|
182 info.owner = list
|
adam@0
|
183 info.fontObject = "GameFontHighlightLarge"
|
adam@0
|
184 info.minWidth = 140
|
adam@0
|
185 return info
|
adam@0
|
186 end
|
adam@0
|
187
|
adam@0
|
188 -- Create and bind the initialization function to the dropdown menu
|
adam@0
|
189 UIDropDownMenu_Initialize(tab.dropDown, function(self, level, menuList)
|
yellowfive@11
|
190 UIDropDownMenu_AddButton(AddButton(self, L.AMR_SHOPPINGLISTTAB_DROPDOWN_FRIEND))
|
yellowfive@11
|
191 UIDropDownMenu_AddButton(AddButton(self, L.AMR_SHOPPINGLISTTAB_DROPDOWN_PARTY))
|
yellowfive@11
|
192 UIDropDownMenu_AddButton(AddButton(self, L.AMR_SHOPPINGLISTTAB_DROPDOWN_RAID))
|
yellowfive@11
|
193 UIDropDownMenu_AddButton(AddButton(self, L.AMR_SHOPPINGLISTTAB_DROPDOWN_GUILD))
|
yellowfive@11
|
194 UIDropDownMenu_AddButton(AddButton(self, L.AMR_SHOPPINGLISTTAB_DROPDOWN_CHANNEL))
|
yellowfive@11
|
195 UIDropDownMenu_AddButton(AddButton(self, L.AMR_SHOPPINGLISTTAB_DROPDOWN_MAIL))
|
adam@0
|
196 end)
|
adam@0
|
197
|
adam@0
|
198 function tab.dropDown:SetValue(newValue)
|
adam@0
|
199 AmrSendSettings.SendToType = newValue
|
adam@0
|
200 -- Update the text; if we merely wanted it to display newValue, we would not need to do this
|
adam@0
|
201 UIDropDownMenu_SetText(tab.dropDown, AmrSendSettings.SendToType)
|
adam@0
|
202 -- Because this is called from a sub-menu, only that menu level is closed by default.
|
adam@0
|
203 -- Close the entire menu with this next call
|
adam@0
|
204 CloseDropDownMenus()
|
adam@0
|
205 end
|
adam@0
|
206
|
adam@0
|
207 tab.sendTo = CreateFrame("EditBox", "AmrSendTo", tab.shoppingPanel, "InputBoxTemplate" )
|
adam@0
|
208 tab.sendTo:SetPoint("TOPLEFT", tab.dropDown, "TOPRIGHT", 0, 0)
|
adam@0
|
209 tab.sendTo:SetPoint("RIGHT", 0, 0)
|
adam@0
|
210 tab.sendTo:SetHeight(30)
|
adam@0
|
211 tab.sendTo:SetText(AmrSendSettings.SendTo or "")
|
adam@0
|
212 tab.sendTo:SetFontObject("GameFontHighlightLarge")
|
adam@0
|
213 tab.sendTo:SetAutoFocus(false)
|
adam@0
|
214 tab.sendTo:SetScript("OnChar", function()
|
adam@0
|
215 AmrSendSettings.SendTo = tab.sendTo:GetText()
|
adam@0
|
216 end)
|
adam@0
|
217
|
adam@0
|
218 tab.messageQueue = {}
|
adam@0
|
219 return tab
|
adam@0
|
220 end
|
adam@0
|
221
|
adam@0
|
222 -- display a gem icon in a row
|
adam@0
|
223 -- gemInfo is {id, enchantId, color, count }
|
adam@0
|
224 function AskMrRobot.ShoppingListTab:SetGemIcon(row, gemInfo)
|
adam@0
|
225 -- get gem icon for the row
|
adam@0
|
226 local gemIcon = self.gemIcons[row]
|
adam@0
|
227
|
adam@0
|
228 -- if we don't have one
|
adam@0
|
229 if gemIcon == nil then
|
adam@0
|
230 -- make one
|
adam@0
|
231 gemIcon = AskMrRobot.GemIcon:new(nil, self.scrollParent)
|
adam@0
|
232 self.gemIcons[row] = gemIcon
|
adam@0
|
233 gemIcon:SetScript("OnMouseDown", function()
|
adam@0
|
234 self:SearchForGem(row)
|
adam@0
|
235 end)
|
adam@0
|
236
|
adam@0
|
237 -- position it
|
adam@0
|
238 local previous = self.gemsHeader
|
adam@0
|
239 if row > 1 then
|
adam@0
|
240 previous = self.gemIcons[row - 1]
|
adam@0
|
241 end
|
adam@0
|
242 gemIcon:SetPoint("TOPLEFT", previous, "BOTTOMLEFT", 0, -7)
|
adam@0
|
243
|
adam@0
|
244 -- size it
|
adam@0
|
245 gemIcon:SetWidth(24)
|
adam@0
|
246 gemIcon:SetHeight(24)
|
adam@0
|
247
|
adam@0
|
248 -- give it a nice border
|
adam@0
|
249 gemIcon:SetRoundBorder()
|
adam@0
|
250 end
|
adam@0
|
251
|
adam@0
|
252 gemIcon:Show()
|
adam@0
|
253
|
adam@0
|
254 -- make a link for the optimized gem
|
adam@0
|
255 gemLink = select(2, GetItemInfo(gemInfo.id))
|
adam@0
|
256
|
adam@0
|
257 -- set the link (tooltip + icon)
|
adam@0
|
258 gemIcon:SetItemLink(gemLink)
|
adam@0
|
259 gemIcon:SetGemColor(gemInfo.color)
|
adam@0
|
260
|
adam@0
|
261 -- if we didn't get one, its because WoW is slow
|
adam@0
|
262 if not gemLink and gemInfo.id then
|
adam@0
|
263 -- when WoW finally returns the link, set the icon / tooltip
|
adam@0
|
264 AskMrRobot.RegisterItemInfoCallback(gemInfo.id, function(name, link)
|
adam@0
|
265 gemIcon:SetItemLink(link)
|
adam@0
|
266 end)
|
adam@0
|
267 end
|
adam@0
|
268
|
adam@0
|
269 end
|
adam@0
|
270
|
adam@0
|
271
|
adam@0
|
272 -- display a gem icon in a row
|
adam@0
|
273 -- gemInfo is {id, enchantId, color, count }
|
adam@0
|
274 function AskMrRobot.ShoppingListTab:SetGemText(row, gemInfo)
|
adam@0
|
275 -- get gem icon for the row
|
adam@0
|
276 local gemText = self.gemLinks[row]
|
adam@0
|
277
|
adam@0
|
278 -- if we don't have one
|
adam@0
|
279 if gemText == nil then
|
adam@0
|
280 -- make one
|
adam@0
|
281 gemText = AskMrRobot.ItemLinkText:new(nil, self.scrollParent)
|
adam@0
|
282 self.gemLinks[row] = gemText
|
adam@0
|
283 gemText:SetScript("OnMouseDown", function()
|
adam@0
|
284 self:SearchForGem(row)
|
adam@0
|
285 end)
|
adam@0
|
286
|
adam@0
|
287 -- position it
|
adam@0
|
288 local previous = self.gemsHeader
|
adam@0
|
289 if row > 1 then
|
adam@0
|
290 previous = self.gemIcons[row - 1]
|
adam@0
|
291 end
|
adam@0
|
292 gemText:SetPoint("TOPLEFT", previous, "BOTTOMLEFT", 30, -8)
|
adam@0
|
293 gemText:SetPoint("RIGHT", self, "RIGHT", -70, 0)
|
adam@0
|
294 gemText:SetHeight(18)
|
adam@0
|
295 gemText:SetFontSize(15)
|
adam@0
|
296 end
|
adam@0
|
297
|
adam@0
|
298 gemText:Show()
|
adam@0
|
299
|
adam@0
|
300 gemText:SetItemId(gemInfo.id)
|
adam@0
|
301 end
|
adam@0
|
302
|
adam@0
|
303 -- display a gem icon in a row
|
adam@0
|
304 -- gemInfo is {id, enchantId, color, count }
|
adam@0
|
305 function AskMrRobot.ShoppingListTab:SetGemQuantity(row, qty, total)
|
adam@0
|
306 if qty > total then qty = total end
|
adam@0
|
307
|
adam@0
|
308 -- get gem icon for the row
|
adam@0
|
309 local gemText = self.gemQuantity[row]
|
adam@0
|
310
|
adam@0
|
311 -- if we don't have one
|
adam@0
|
312 if gemText == nil then
|
adam@0
|
313 -- make one
|
adam@0
|
314 gemText = AskMrRobot.FontString:new(self.scrollParent, nil, "ARTWORK", "GameFontNormalLarge")
|
adam@0
|
315 self.gemQuantity[row] = gemText
|
adam@0
|
316
|
adam@0
|
317 -- position it
|
adam@0
|
318 local previous = self.gemsHeader
|
adam@0
|
319 if row > 1 then
|
adam@0
|
320 previous = self.gemIcons[row - 1]
|
adam@0
|
321 end
|
adam@0
|
322 gemText:SetPoint("TOPLEFT", previous, "BOTTOMLEFT", 370, -8)
|
adam@0
|
323 gemText:SetHeight(18)
|
adam@0
|
324 gemText:SetFontSize(15)
|
adam@0
|
325 end
|
adam@0
|
326
|
adam@0
|
327 gemText:SetText('' .. qty .. '/' .. total)
|
adam@0
|
328 if qty == total then
|
adam@0
|
329 gemText:SetTextColor(0,1,0)
|
adam@0
|
330 else
|
adam@0
|
331 gemText:SetTextColor(1,0,0)
|
adam@0
|
332 end
|
adam@0
|
333 gemText:Show()
|
adam@0
|
334 end
|
adam@0
|
335
|
adam@0
|
336
|
adam@0
|
337 -- display an enchant icon in a row
|
adam@0
|
338 function AskMrRobot.ShoppingListTab:SetEnchantIcon(row, enchantId)
|
adam@0
|
339
|
adam@0
|
340 -- get enchant icon for the row
|
adam@0
|
341 local enchantIcon = self.enchantIcons[row]
|
adam@0
|
342
|
adam@0
|
343 -- if we don't have one
|
adam@0
|
344 if enchantIcon == nil then
|
adam@0
|
345 -- make one
|
adam@0
|
346 enchantIcon = AskMrRobot.EnchantLinkIconAndText:new(nil, self.scrollParent)
|
adam@0
|
347 self.enchantIcons[row] = enchantIcon
|
adam@0
|
348 enchantIcon:SetScript("OnMouseDown", function()
|
adam@0
|
349 self:SearchForEnchant(row)
|
adam@0
|
350 end)
|
adam@0
|
351
|
adam@0
|
352 -- position it
|
adam@0
|
353 if row == 1 then
|
adam@0
|
354 enchantIcon:SetPoint("TOPLEFT", self.enchantsHeader, "BOTTOMLEFT", 0, -12)
|
adam@0
|
355 enchantIcon:SetPoint("RIGHT", self.scrollParent, "RIGHT", -30, 0)
|
adam@0
|
356 else
|
adam@0
|
357 enchantIcon:SetPoint("TOPLEFT", self.enchantIcons[row - 1], "BOTTOMLEFT", 0, -7)
|
adam@0
|
358 enchantIcon:SetPoint("RIGHT", self.scrollParent, "RIGHT", -30, 0)
|
adam@0
|
359 end
|
adam@0
|
360
|
adam@0
|
361 -- size it
|
adam@0
|
362 enchantIcon:SetWidth(24)
|
adam@0
|
363 enchantIcon:SetHeight(24)
|
adam@0
|
364 enchantIcon:SetFontSize(15)
|
adam@0
|
365
|
adam@0
|
366 -- give it a nice border
|
adam@0
|
367 enchantIcon:SetRoundBorder()
|
adam@0
|
368
|
adam@0
|
369 enchantIcon:UseSpellName()
|
adam@0
|
370 end
|
adam@0
|
371
|
adam@0
|
372 enchantIcon:SetEnchantId(enchantId)
|
adam@0
|
373
|
adam@0
|
374 enchantIcon:Show()
|
adam@0
|
375 end
|
adam@0
|
376
|
adam@0
|
377 -- display a gem icon in a row
|
adam@0
|
378 -- gemInfo is {id, enchantId, color, count }
|
adam@0
|
379 function AskMrRobot.ShoppingListTab:SetEnchantQuantity(row, qty, total)
|
adam@0
|
380 if qty > total then qty = total end
|
adam@0
|
381
|
adam@0
|
382 -- get gem icon for the row
|
adam@0
|
383 local enchantText = self.enchantQuantity[row]
|
adam@0
|
384
|
adam@0
|
385 -- if we don't have one
|
adam@0
|
386 if enchantText == nil then
|
adam@0
|
387 -- make one
|
adam@0
|
388 enchantText = AskMrRobot.FontString:new(self.scrollParent, nil, "ARTWORK", "GameFontNormalLarge")
|
adam@0
|
389 self.enchantQuantity[row] = enchantText
|
adam@0
|
390
|
adam@0
|
391 -- position it
|
adam@0
|
392 local previous = self.enchantsHeader
|
adam@0
|
393 if row > 1 then
|
adam@0
|
394 previous = self.enchantIcons[row - 1]
|
adam@0
|
395 end
|
adam@0
|
396 enchantText:SetPoint("TOPLEFT", previous, "BOTTOMLEFT", 370, -8)
|
adam@0
|
397 enchantText:SetHeight(18)
|
adam@0
|
398 enchantText:SetFontSize(15)
|
adam@0
|
399 end
|
adam@0
|
400
|
adam@0
|
401 enchantText:SetText('' .. qty .. '/' .. total)
|
adam@0
|
402 if qty == total then
|
adam@0
|
403 enchantText:SetTextColor(0,1,0)
|
adam@0
|
404 else
|
adam@0
|
405 enchantText:SetTextColor(1,0,0)
|
adam@0
|
406 end
|
adam@0
|
407 enchantText:Show()
|
adam@0
|
408 end
|
adam@0
|
409
|
adam@0
|
410 function AskMrRobot.ShoppingListTab:SearchForItem(itemName)
|
adam@0
|
411 if self.isAuctionHouseVisible then
|
adam@0
|
412 QueryAuctionItems(itemName, nil, nil, 0, 0, 0, 0, 0, 0, 0)
|
adam@0
|
413 end
|
adam@0
|
414 end
|
adam@0
|
415
|
adam@0
|
416 function AskMrRobot.ShoppingListTab:SearchForGem(row)
|
adam@0
|
417 self:SearchForItem(self.gemLinks[row].itemName)
|
adam@0
|
418 end
|
adam@0
|
419
|
adam@0
|
420 function AskMrRobot.ShoppingListTab:SearchForEnchant(row)
|
adam@0
|
421 self:SearchForItem(self.enchantIcons[row].itemName)
|
adam@0
|
422 end
|
adam@0
|
423
|
adam@0
|
424 function AskMrRobot.ShoppingListTab:SearchForEnchantMaterial(row)
|
adam@0
|
425 self:SearchForItem(self.enchantMaterialLinks[row].itemName)
|
adam@0
|
426 end
|
adam@0
|
427
|
adam@0
|
428
|
adam@0
|
429 -- display an enchant material icon in a row
|
adam@0
|
430 function AskMrRobot.ShoppingListTab:SetEnchantMaterialIcon(row, itemId)
|
adam@0
|
431 -- get enchant material icon for the row
|
adam@0
|
432 local materialIcon = self.enchantMaterialIcons[row]
|
adam@0
|
433
|
adam@0
|
434 -- if we don't have one
|
adam@0
|
435 if materialIcon == nil then
|
adam@0
|
436 -- make one
|
adam@0
|
437 materialIcon = AskMrRobot.ItemIcon:new(nil, self.scrollParent)
|
adam@0
|
438 self.enchantMaterialIcons[row] = materialIcon
|
adam@0
|
439 materialIcon:SetScript("OnMouseDown", function()
|
adam@0
|
440 self:SearchForEnchantMaterial(row)
|
adam@0
|
441 end)
|
adam@0
|
442
|
adam@0
|
443 -- position it
|
adam@0
|
444 local previous = self.enchantMaterialsHeader
|
adam@0
|
445 if row > 1 then
|
adam@0
|
446 previous = self.enchantMaterialIcons[row - 1]
|
adam@0
|
447 end
|
adam@0
|
448 materialIcon:SetPoint("TOPLEFT", previous, "BOTTOMLEFT", 0, -7)
|
adam@0
|
449
|
adam@0
|
450 -- size it
|
adam@0
|
451 materialIcon:SetWidth(24)
|
adam@0
|
452 materialIcon:SetHeight(24)
|
adam@0
|
453
|
adam@0
|
454 -- give it a nice border
|
adam@0
|
455 materialIcon:SetRoundBorder()
|
adam@0
|
456 end
|
adam@0
|
457
|
adam@0
|
458 materialIcon:Show()
|
adam@0
|
459
|
adam@0
|
460 -- make a link for the optimized gem
|
adam@0
|
461 local itemLink = select(2, GetItemInfo(itemId))
|
adam@0
|
462
|
adam@0
|
463 materialIcon:SetItemLink(itemLink)
|
adam@0
|
464
|
adam@0
|
465 -- if we didn't get one, its because WoW is slow
|
adam@0
|
466 if not itemLink and itemId then
|
adam@0
|
467 -- when WoW finally returns the link, set the icon / tooltip
|
adam@0
|
468 AskMrRobot.RegisterItemInfoCallback(itemId, function(name, link)
|
adam@0
|
469 materialIcon:SetItemLink(link)
|
adam@0
|
470 end)
|
adam@0
|
471 end
|
adam@0
|
472 end
|
adam@0
|
473
|
adam@0
|
474
|
adam@0
|
475 -- display an enchant material link in a row
|
adam@0
|
476 function AskMrRobot.ShoppingListTab:SetEnchantMaterialLink(row, itemId)
|
adam@0
|
477 -- get gem icon for the row
|
adam@0
|
478 local materialLink = self.enchantMaterialLinks[row]
|
adam@0
|
479
|
adam@0
|
480 -- if we don't have one
|
adam@0
|
481 if materialLink == nil then
|
adam@0
|
482 -- make one
|
adam@0
|
483 materialLink = AskMrRobot.ItemLinkText:new(nil, self.scrollParent)
|
adam@0
|
484 self.enchantMaterialLinks[row] = materialLink
|
adam@0
|
485 materialLink:SetScript("OnMouseDown", function()
|
adam@0
|
486 self:SearchForEnchantMaterial(row)
|
adam@0
|
487 end)
|
adam@0
|
488
|
adam@0
|
489 -- position it
|
adam@0
|
490 local previous = self.enchantMaterialsHeader
|
adam@0
|
491 if row > 1 then
|
adam@0
|
492 previous = self.enchantMaterialIcons[row - 1]
|
adam@0
|
493 end
|
adam@0
|
494 materialLink:SetPoint("TOPLEFT", previous, "BOTTOMLEFT", 30, -8)
|
adam@0
|
495 materialLink:SetPoint("RIGHT", self, "RIGHT", -30, 0)
|
adam@0
|
496 materialLink:SetHeight(18)
|
adam@0
|
497 materialLink:SetFontSize(15)
|
adam@0
|
498 end
|
adam@0
|
499
|
adam@0
|
500 materialLink:Show()
|
adam@0
|
501
|
adam@0
|
502 materialLink:SetItemId(itemId)
|
adam@0
|
503 materialLink.itemId = itemId
|
adam@0
|
504 end
|
adam@0
|
505
|
adam@0
|
506 -- display a gem icon in a row
|
adam@0
|
507 -- gemInfo is {id, enchantId, color, count }
|
adam@0
|
508 function AskMrRobot.ShoppingListTab:SetEnchantMaterialQuantity(row, qty, total)
|
adam@0
|
509 if qty > total then qty = total end
|
adam@0
|
510
|
adam@0
|
511 -- get gem icon for the row
|
adam@0
|
512 local enchantText = self.enchantMaterialQuantity[row]
|
adam@0
|
513
|
adam@0
|
514 -- if we don't have one
|
adam@0
|
515 if enchantText == nil then
|
adam@0
|
516 -- make one
|
adam@0
|
517 enchantText = AskMrRobot.FontString:new(self.scrollParent, nil, "ARTWORK", "GameFontNormalLarge")
|
adam@0
|
518 self.enchantMaterialQuantity[row] = enchantText
|
adam@0
|
519
|
adam@0
|
520 -- position it
|
adam@0
|
521 local previous = self.enchantMaterialsHeader
|
adam@0
|
522 if row > 1 then
|
adam@0
|
523 previous = self.enchantMaterialIcons[row - 1]
|
adam@0
|
524 end
|
adam@0
|
525 enchantText:SetPoint("TOPLEFT", previous, "BOTTOMLEFT", 370, -8)
|
adam@0
|
526 enchantText:SetHeight(18)
|
adam@0
|
527 enchantText:SetFontSize(15)
|
adam@0
|
528 end
|
adam@0
|
529
|
adam@0
|
530 enchantText:SetText('' .. qty .. '/' .. total)
|
adam@0
|
531 if qty == total then
|
adam@0
|
532 enchantText:SetTextColor(0,1,0)
|
adam@0
|
533 else
|
adam@0
|
534 enchantText:SetTextColor(1,0,0)
|
adam@0
|
535 end
|
adam@0
|
536 enchantText:Show()
|
adam@0
|
537 end
|
adam@0
|
538
|
adam@0
|
539 function AskMrRobot.ShoppingListTab:HasStuffToBuy()
|
adam@0
|
540
|
adam@0
|
541 local gemList, enchantList, enchantMaterials = self:CalculateItems()
|
adam@0
|
542
|
adam@0
|
543 local count = 0
|
adam@0
|
544 for gemId, gemInfo in AskMrRobot.spairs(gemList) do
|
adam@0
|
545 count = count + gemInfo.total - gemInfo.count
|
adam@0
|
546 end
|
adam@0
|
547 for slot, enchant in AskMrRobot.spairs(enchantList) do
|
adam@0
|
548 count = count + enchant.total - enchant.count
|
adam@0
|
549 end
|
adam@0
|
550
|
adam@0
|
551 return count > 0
|
adam@0
|
552 end
|
adam@0
|
553
|
adam@0
|
554 function AskMrRobot.ShoppingListTab:CalculateItems()
|
adam@0
|
555 -- build a map of missing gem-ids -> {id, color, enchantid, count, total}
|
adam@0
|
556 local gemList = {}
|
adam@0
|
557 for slotNum, badGems in pairs(AskMrRobot.itemDiffs.gems) do
|
adam@0
|
558 --badGems: {current: array of enchant ids, optimized: (array of {id, color, enchantId})
|
adam@0
|
559 for i = 1, #badGems.optimized do
|
adam@0
|
560 if badGems.badGems[i] then
|
adam@0
|
561 local goodGem = badGems.optimized[i]
|
adam@0
|
562 if goodGem.id ~= 0 then
|
adam@0
|
563 local gem = gemList[goodGem.id]
|
adam@0
|
564 if gem == nil then
|
adam@0
|
565 gemList[goodGem.id] = {id = goodGem.id, enchantId = goodGem.enchantId, color = goodGem.color, count = 0, total = 1}
|
adam@0
|
566 else
|
adam@0
|
567 gem.total = gem.total + 1
|
adam@0
|
568 end
|
adam@0
|
569 end
|
adam@0
|
570 end
|
adam@0
|
571 end
|
adam@0
|
572 end
|
adam@0
|
573
|
adam@0
|
574 local enchantList = {}
|
adam@0
|
575 for slot, enchantData in AskMrRobot.sortSlots(AskMrRobot.itemDiffs.enchants) do
|
adam@0
|
576 local id = AskMrRobot.getEnchantItemId(enchantData.optimized) or enchantData.optimized
|
adam@0
|
577 local qty = enchantList[id]
|
adam@0
|
578 if qty then
|
adam@0
|
579 qty.total = qty.total + 1
|
adam@0
|
580 else
|
adam@0
|
581 qty = { count = 0, total = 1, optimized = enchantData.optimized }
|
adam@0
|
582 enchantList[id] = qty
|
adam@0
|
583 end
|
adam@0
|
584 end
|
adam@0
|
585
|
adam@0
|
586 local enchantMaterials = {}
|
adam@0
|
587 for slot, enchantData in pairs(AskMrRobot.itemDiffs.enchants) do
|
adam@0
|
588 AskMrRobot.addEnchantMaterials(enchantMaterials, enchantData.optimized)
|
adam@0
|
589 end
|
adam@0
|
590
|
adam@0
|
591 --substract any inventory we already have in the bank
|
adam@0
|
592 for i = 1, #AmrBankItemsAndCounts do
|
adam@0
|
593 local itemId = AskMrRobot.getItemIdFromLink(AmrBankItemsAndCounts[i].link)
|
adam@0
|
594 if itemId then
|
adam@0
|
595 local gem = gemList[itemId]
|
adam@0
|
596 if gem then
|
adam@0
|
597 gem.count = gem.count + AmrBankItemsAndCounts[i].count
|
adam@0
|
598 else
|
adam@0
|
599 local alternateGemId = AskMrRobot.gemDuplicates[itemId]
|
adam@0
|
600 if alternateGemId then
|
adam@0
|
601 gem = gemList[alternateGemId]
|
adam@0
|
602 if gem then
|
adam@0
|
603 gem.count = gem.count + AmrBankItemsAndCounts[i].count
|
adam@0
|
604 end
|
adam@0
|
605 end
|
adam@0
|
606 end
|
adam@0
|
607 local material = enchantMaterials[itemId]
|
adam@0
|
608 if material then
|
adam@0
|
609 material.count = material.count + AmrBankItemsAndCounts[i].count
|
adam@0
|
610 end
|
adam@0
|
611 local enchant = enchantList[itemId]
|
adam@0
|
612 if enchant then
|
adam@0
|
613 enchant.count = enchant.count + AmrBankItemsAndCounts[i].count
|
adam@0
|
614 end
|
adam@0
|
615 end
|
adam@0
|
616 end
|
adam@0
|
617
|
adam@0
|
618 local _ , bagItemsWithCount = AskMrRobot.ScanBags()
|
adam@0
|
619
|
adam@0
|
620 --substract any inventory we already have in bags
|
adam@0
|
621 for i = 1, #bagItemsWithCount do
|
adam@0
|
622 local itemId = AskMrRobot.getItemIdFromLink(bagItemsWithCount[i].link)
|
adam@0
|
623 if itemId then
|
adam@0
|
624 local gem = gemList[itemId]
|
adam@0
|
625 if gem then
|
adam@0
|
626 gem.count = gem.count + bagItemsWithCount[i].count
|
adam@0
|
627 else
|
adam@0
|
628 local alternateGemId = AskMrRobot.gemDuplicates[itemId]
|
adam@0
|
629 if alternateGemId then
|
adam@0
|
630 gem = gemList[alternateGemId]
|
adam@0
|
631 if gem then
|
adam@0
|
632 gem.count = gem.count + bagItemsWithCount[i].count
|
adam@0
|
633 end
|
adam@0
|
634 end
|
adam@0
|
635 end
|
adam@0
|
636 local material = enchantMaterials[itemId]
|
adam@0
|
637 if material then
|
adam@0
|
638 material.count = material.count + bagItemsWithCount[i].count
|
adam@0
|
639 end
|
adam@0
|
640 local enchant = enchantList[itemId]
|
adam@0
|
641 if enchant then
|
adam@0
|
642 enchant.count = enchant.count + bagItemsWithCount[i].count
|
adam@0
|
643 end
|
adam@0
|
644 end
|
adam@0
|
645 end
|
adam@0
|
646
|
adam@0
|
647 return gemList, enchantList, enchantMaterials
|
adam@0
|
648 end
|
adam@0
|
649
|
adam@0
|
650 function AskMrRobot.ShoppingListTab:Update()
|
adam@0
|
651
|
adam@0
|
652 local gemList, enchantList, enchantMaterials = self:CalculateItems()
|
adam@0
|
653
|
adam@0
|
654 -- update the UI
|
adam@0
|
655 local lastControl = nil
|
adam@0
|
656 local row = 1
|
adam@0
|
657 for gemId, gemInfo in AskMrRobot.spairs(gemList) do
|
adam@0
|
658 self:SetGemIcon(row, gemInfo)
|
adam@0
|
659 self:SetGemText(row, gemInfo)
|
adam@0
|
660 self:SetGemQuantity(row, gemInfo.count, gemInfo.total)
|
adam@0
|
661 lastControl = self.gemIcons[row]
|
adam@0
|
662 row = row + 1
|
adam@0
|
663 end
|
adam@0
|
664
|
adam@0
|
665 -- hide any extra gem icons
|
adam@0
|
666 for i = row, #self.gemIcons do
|
adam@0
|
667 self.gemIcons[i]:Hide()
|
adam@0
|
668 self.gemLinks[i]:Hide()
|
adam@0
|
669 self.gemQuantity[i]:Hide()
|
adam@0
|
670 end
|
adam@0
|
671
|
adam@0
|
672 -- hide / show the gems header, and position the enchant headers
|
adam@0
|
673 if row > 1 then
|
adam@0
|
674 self.gemsHeader:Show()
|
adam@0
|
675 self.gemsQuantityHeader:Show()
|
adam@0
|
676 self.enchantsHeader:SetPoint("TOPLEFT", self.gemIcons[row - 1], "BOTTOMLEFT", 0, -15)
|
adam@0
|
677 else
|
adam@0
|
678 self.gemsHeader:Hide()
|
adam@0
|
679 self.gemsQuantityHeader:Hide()
|
adam@0
|
680 self.enchantsHeader:SetPoint("TOPLEFT", self.scrollParent, "TOPLEFT", 0, 0)
|
adam@0
|
681 end
|
adam@0
|
682
|
adam@0
|
683 row = 1
|
adam@0
|
684 for slot, enchant in AskMrRobot.spairs(enchantList) do
|
adam@0
|
685 self:SetEnchantIcon(row, enchant.optimized)
|
adam@0
|
686 self:SetEnchantQuantity(row, enchant.count, enchant.total)
|
adam@0
|
687 lastControl = self.enchantIcons[row]
|
adam@0
|
688 row = row + 1
|
adam@0
|
689 end
|
adam@0
|
690
|
adam@0
|
691 -- hide any extra enchant icons
|
adam@0
|
692 for i = row, #self.enchantIcons do
|
adam@0
|
693 self.enchantIcons[i]:Hide()
|
adam@0
|
694 self.enchantQuantity[i]:Hide()
|
adam@0
|
695 end
|
adam@0
|
696
|
adam@0
|
697 -- hide / show the enchants header, and position the enchant materials headers
|
adam@0
|
698 if row > 1 then
|
adam@0
|
699 self.enchantsHeader:Show()
|
adam@0
|
700 self.enchantsQuantityHeader:Show()
|
adam@0
|
701 self.enchantMaterialsHeader:SetPoint("TOPLEFT", self.enchantIcons[row - 1], "BOTTOMLEFT", 0, -15)
|
adam@0
|
702 else
|
adam@0
|
703 self.enchantsHeader:Hide()
|
adam@0
|
704 self.enchantsQuantityHeader:Hide()
|
adam@0
|
705 self.enchantMaterialsHeader:SetPoint("TOPLEFT", self.scrollParent, "TOPLEFT", 0, 0)
|
adam@0
|
706 end
|
adam@0
|
707
|
adam@0
|
708 row = 1
|
adam@0
|
709 for itemId, count in AskMrRobot.spairs(enchantMaterials) do
|
adam@0
|
710 self:SetEnchantMaterialIcon(row, itemId)
|
adam@0
|
711 self:SetEnchantMaterialLink(row, itemId)
|
adam@0
|
712 self:SetEnchantMaterialQuantity(row, count.count, count.total)
|
adam@0
|
713 lastControl = self.enchantMaterialIcons[row]
|
adam@0
|
714 row = row + 1
|
adam@0
|
715 end
|
adam@0
|
716
|
adam@0
|
717 for i = row, #self.enchantMaterialIcons do
|
adam@0
|
718 self.enchantMaterialIcons[i]:Hide()
|
adam@0
|
719 self.enchantMaterialLinks[i]:Hide()
|
adam@0
|
720 self.enchantMaterialQuantity[i]:Hide()
|
adam@0
|
721 end
|
adam@0
|
722
|
adam@0
|
723 if row == 1 then
|
adam@0
|
724 self.enchantMaterialsHeader:Hide()
|
adam@0
|
725 self.enchantMaterialsQuantityHeader:Hide()
|
adam@0
|
726 else
|
adam@0
|
727 self.enchantMaterialsHeader:Show()
|
adam@0
|
728 self.enchantMaterialsQuantityHeader:Show()
|
adam@0
|
729 end
|
adam@0
|
730
|
adam@0
|
731 -- fix up the scrollbar length
|
adam@0
|
732 if lastControl then
|
adam@0
|
733 local height = self.scrollParent:GetTop() - lastControl:GetBottom()
|
adam@0
|
734 self.scrollParent:SetHeight(height)
|
adam@0
|
735 if height < self.scrollFrame:GetHeight() then
|
adam@0
|
736 self.scrollFrame.ScrollBar:Hide()
|
adam@0
|
737 else
|
adam@0
|
738 self.scrollFrame:Show()
|
adam@0
|
739 self.scrollFrame.ScrollBar:Show()
|
adam@0
|
740 end
|
adam@0
|
741 self.stamp:Hide()
|
adam@0
|
742 self.shoppingPanel:Show()
|
adam@0
|
743 else
|
adam@0
|
744 self.scrollFrame.ScrollBar:Hide()
|
adam@0
|
745 self.shoppingPanel:Hide()
|
adam@0
|
746 self.stamp:Show()
|
adam@0
|
747 end
|
adam@0
|
748 end
|
adam@0
|
749
|
adam@0
|
750
|
adam@0
|
751 function AskMrRobot.ShoppingListTab:OnEvent(frame, event, ...)
|
adam@0
|
752 local handler = self["On_" .. event]
|
adam@0
|
753 if handler then
|
adam@0
|
754 handler(self, ...)
|
adam@0
|
755 end
|
adam@0
|
756 end
|
adam@0
|
757
|
adam@0
|
758 function AskMrRobot.ShoppingListTab:On_MAIL_SHOW()
|
adam@0
|
759 self.mailOpen = true
|
adam@0
|
760 end
|
adam@0
|
761
|
adam@0
|
762 function AskMrRobot.ShoppingListTab:On_MAIL_CLOSED()
|
adam@0
|
763 self.mailOpen = nil
|
adam@0
|
764 end
|
adam@0
|
765
|
adam@0
|
766 function AskMrRobot.ShoppingListTab:On_AUCTION_HOUSE_SHOW()
|
adam@0
|
767 self.isAuctionHouseVisible = true
|
adam@0
|
768 end
|
adam@0
|
769
|
adam@0
|
770 function AskMrRobot.ShoppingListTab:On_AUCTION_HOUSE_CLOSED()
|
adam@0
|
771 self.isAuctionHouseVisible = false
|
adam@0
|
772 end
|
adam@0
|
773
|
adam@0
|
774 function AskMrRobot.ShoppingListTab:sendMail()
|
adam@0
|
775
|
adam@0
|
776 -- need mail window to be open for this to work
|
adam@0
|
777 if not self.mailOpen then
|
adam@0
|
778 StaticPopup_Show("SHOPPING_TAB_PLEASE_OPEN")
|
adam@0
|
779 return
|
adam@0
|
780 end
|
adam@0
|
781
|
yellowfive@11
|
782 local message = L.AMR_SHOPPINGLISTTAB_MAIL_ROBOT_MESSAGE
|
adam@0
|
783
|
adam@0
|
784 local gemList, enchantList, enchantMaterials = self:CalculateItems()
|
adam@0
|
785
|
adam@0
|
786 if AmrSendSettings.SendGems then
|
adam@0
|
787 for k,v in pairs(gemList) do
|
adam@0
|
788 --exclude jewelcrafter gems
|
adam@0
|
789 if not AskMrRobot.JewelcrafterGems[k] then
|
adam@0
|
790 local needed = v.total - v.count
|
adam@0
|
791 if needed > 0 then
|
adam@0
|
792 local itemName = GetItemInfo(k)
|
adam@0
|
793 if itemName then
|
adam@0
|
794 message = message .. "\n" .. needed .. "x " .. itemName
|
adam@0
|
795 end
|
adam@0
|
796 end
|
adam@0
|
797 end
|
adam@0
|
798 end
|
adam@0
|
799 end
|
adam@0
|
800
|
adam@0
|
801 if AmrSendSettings.SendEnchants then
|
adam@0
|
802 for k,v in pairs(enchantList) do
|
adam@0
|
803 local needed = v.total - v.count
|
adam@0
|
804 if needed > 0 then
|
adam@0
|
805 local itemName = GetItemInfo(k)
|
adam@0
|
806 if itemName then
|
adam@0
|
807 message = message .. "\n" .. needed .. "x " .. itemName
|
adam@0
|
808 end
|
adam@0
|
809 end
|
adam@0
|
810 end
|
adam@0
|
811 end
|
adam@0
|
812
|
adam@0
|
813 if AmrSendSettings.SendEnchantMaterials then
|
adam@0
|
814 for k,v in pairs(enchantMaterials) do
|
adam@0
|
815 local needed = v.total - v.count
|
adam@0
|
816 if needed > 0 then
|
adam@0
|
817 local itemName = GetItemInfo(k)
|
adam@0
|
818 if itemName then
|
adam@0
|
819 message = message .. "\n" .. needed .. "x " .. itemName
|
adam@0
|
820 end
|
adam@0
|
821 end
|
adam@0
|
822 end
|
adam@0
|
823 end
|
adam@0
|
824
|
adam@0
|
825 MailFrameTab_OnClick(nil, 2)
|
adam@0
|
826 if AmrSendSettings.SendGems then
|
adam@0
|
827 if AmrSendSettings.SendEnchants then
|
yellowfive@11
|
828 SendMailSubjectEditBox:SetText(L.AMR_SHOPPINGLISTTAB_MAIL_SUBJECT_GE)
|
adam@0
|
829 else
|
yellowfive@11
|
830 SendMailSubjectEditBox:SetText(L.AMR_SHOPPINGLISTTAB_MAIL_SUBJECT_G)
|
adam@0
|
831 end
|
adam@0
|
832 else
|
yellowfive@11
|
833 SendMailSubjectEditBox:SetText(L.AMR_SHOPPINGLISTTAB_MAIL_SUBJECT_E)
|
adam@0
|
834 end
|
adam@0
|
835 SendMailNameEditBox:SetText(AmrSendSettings.SendTo)
|
adam@0
|
836 SendMailBodyEditBox:SetText(message)
|
adam@0
|
837 end
|
adam@0
|
838
|
adam@0
|
839 function AskMrRobot.ShoppingListTab:Send()
|
adam@0
|
840 local chatType = nil
|
yellowfive@11
|
841 if AmrSendSettings.SendToType == L.AMR_SHOPPINGLISTTAB_DROPDOWN_PARTY then
|
adam@0
|
842 chatType = "PARTY"
|
yellowfive@11
|
843 elseif AmrSendSettings.SendToType == L.AMR_SHOPPINGLISTTAB_DROPDOWN_GUILD then
|
adam@0
|
844 chatType = "GUILD"
|
yellowfive@11
|
845 elseif AmrSendSettings.SendToType == L.AMR_SHOPPINGLISTTAB_DROPDOWN_RAID then
|
adam@0
|
846 chatType = "RAID"
|
yellowfive@11
|
847 elseif AmrSendSettings.SendToType == L.AMR_SHOPPINGLISTTAB_DROPDOWN_CHANNEL then
|
adam@0
|
848 chatType = "CHANNEL"
|
yellowfive@11
|
849 elseif AmrSendSettings.SendToType == L.AMR_SHOPPINGLISTTAB_DROPDOWN_MAIL then
|
adam@0
|
850 self:sendMail()
|
adam@0
|
851 return
|
adam@0
|
852 else
|
adam@0
|
853 chatType = "WHISPER"
|
adam@0
|
854 end
|
adam@0
|
855
|
yellowfive@11
|
856 local message = L.AMR_SHOPPINGLISTTAB_CHAT_ROBOT_MESSAGE
|
adam@0
|
857 local count = 0
|
adam@0
|
858
|
adam@0
|
859
|
adam@0
|
860 local gemList, enchantList, enchantMaterials = self:CalculateItems()
|
adam@0
|
861
|
adam@0
|
862 local items = {}
|
adam@0
|
863 if AmrSendSettings.SendGems then
|
adam@0
|
864 for k,v in pairs(gemList) do
|
adam@0
|
865 if not AskMrRobot.JewelcrafterGems[k] then
|
adam@0
|
866 local needed = v.total - v.count
|
adam@0
|
867 if needed > 0 then
|
adam@0
|
868 tinsert(items, {id = k, needed = needed})
|
adam@0
|
869 end
|
adam@0
|
870 end
|
adam@0
|
871 end
|
adam@0
|
872 end
|
adam@0
|
873
|
adam@0
|
874 if AmrSendSettings.SendEnchants then
|
adam@0
|
875 for k,v in pairs(enchantList) do
|
adam@0
|
876 local needed = v.total - v.count
|
adam@0
|
877 if needed > 0 then
|
adam@0
|
878 tinsert(items, {id = k, needed = needed})
|
adam@0
|
879 end
|
adam@0
|
880 end
|
adam@0
|
881 end
|
adam@0
|
882
|
adam@0
|
883 if AmrSendSettings.SendEnchantMaterials then
|
adam@0
|
884 for k,v in pairs(enchantMaterials) do
|
adam@0
|
885 local needed = v.total - v.count
|
adam@0
|
886 if needed > 0 then
|
adam@0
|
887 tinsert(items, {id = k, needed = needed})
|
adam@0
|
888 end
|
adam@0
|
889 end
|
adam@0
|
890 end
|
adam@0
|
891
|
adam@0
|
892 for i, entry in ipairs(items) do
|
adam@0
|
893 local _, link = GetItemInfo(entry.id)
|
adam@0
|
894 if link then
|
adam@0
|
895 message = message .. " " .. entry.needed .. "x " .. link
|
adam@0
|
896 count = count + 1
|
adam@0
|
897 if count == 2 then
|
adam@0
|
898 tinsert(self.messageQueue, {message = message, chatType = chatType, chatChannel = AmrSendSettings.SendTo})
|
adam@0
|
899 count = 0
|
yellowfive@11
|
900 message = L.AMR_SHOPPINGLISTTAB_CHAT_ROBOT_MESSAGE
|
adam@0
|
901 end
|
adam@0
|
902 end
|
adam@0
|
903 end
|
adam@0
|
904
|
adam@0
|
905 if count > 0 then
|
adam@0
|
906 tinsert(self.messageQueue, {message = message, chatType = chatType, chatChannel = AmrSendSettings.SendTo})
|
adam@0
|
907 end
|
adam@0
|
908
|
adam@0
|
909 self:SendNextMessage()
|
adam@0
|
910 end
|
adam@0
|
911
|
adam@0
|
912 function AskMrRobot.ShoppingListTab:SendNextMessage()
|
adam@0
|
913 while #self.messageQueue > 0 do
|
adam@0
|
914 local entry = self.messageQueue[1]
|
adam@0
|
915 table.remove(self.messageQueue, 1)
|
adam@0
|
916 SendChatMessage(entry.message, entry.chatType, nil, entry.chatChannel)
|
adam@0
|
917 end
|
adam@0
|
918 end |