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