comparison ui/ShoppingListTab.lua @ 17:e77e01abce98

Warlords of Draenor pre-patch
author Adam tegen <adam.tegen@gmail.com>
date Mon, 13 Oct 2014 21:28:32 -0500
parents ece9167c0d1c
children a400b906acca
comparison
equal deleted inserted replaced
16:9793e8b683d2 17:e77e01abce98
50 tab.sendButton:SetScript("OnClick", function() 50 tab.sendButton:SetScript("OnClick", function()
51 tab:Send() 51 tab:Send()
52 end) 52 end)
53 53
54 tab.enchantMaterialsCheckbox = CreateFrame("CheckButton", "AmrEnchantMaterialsCheckbox", tab.shoppingPanel, "ChatConfigCheckButtonTemplate"); 54 tab.enchantMaterialsCheckbox = CreateFrame("CheckButton", "AmrEnchantMaterialsCheckbox", tab.shoppingPanel, "ChatConfigCheckButtonTemplate");
55 tab.enchantMaterialsCheckbox:SetChecked(AmrSendSettings.SendEnchantMaterials) 55 tab.enchantMaterialsCheckbox:SetChecked(AmrDb.SendSettings.SendEnchantMaterials)
56 tab.enchantMaterialsCheckbox:SetScript("OnClick", function () AmrSendSettings.SendEnchantMaterials = tab.enchantMaterialsCheckbox:GetChecked() end) 56 tab.enchantMaterialsCheckbox:SetScript("OnClick", function () AmrDb.SendSettings.SendEnchantMaterials = tab.enchantMaterialsCheckbox:GetChecked() end)
57 tab.enchantMaterialsCheckbox:SetPoint("TOPLEFT", tab.sendButton, "TOPLEFT", 0, 25) 57 tab.enchantMaterialsCheckbox:SetPoint("TOPLEFT", tab.sendButton, "TOPLEFT", 0, 25)
58 local text3 = getglobal(tab.enchantMaterialsCheckbox:GetName() .. 'Text') 58 local text3 = getglobal(tab.enchantMaterialsCheckbox:GetName() .. 'Text')
59 text3:SetFontObject("GameFontHighlightLarge") 59 text3:SetFontObject("GameFontHighlightLarge")
60 text3:SetText(L.AMR_SHOPPINGLISTTAB_ENCHANT_MATERIALS) 60 text3:SetText(L.AMR_SHOPPINGLISTTAB_ENCHANT_MATERIALS)
61 text3:SetWidth(150) 61 text3:SetWidth(150)
62 text3:SetPoint("TOPLEFT", tab.enchantMaterialsCheckbox, "TOPRIGHT", 2, -4) 62 text3:SetPoint("TOPLEFT", tab.enchantMaterialsCheckbox, "TOPRIGHT", 2, -4)
63 63
64 64
65 tab.enchantsCheckbox = CreateFrame("CheckButton", "AmrEnchantsCheckbox", tab.shoppingPanel, "ChatConfigCheckButtonTemplate"); 65 tab.enchantsCheckbox = CreateFrame("CheckButton", "AmrEnchantsCheckbox", tab.shoppingPanel, "ChatConfigCheckButtonTemplate");
66 tab.enchantsCheckbox:SetChecked(AmrSendSettings.SendEnchants) 66 tab.enchantsCheckbox:SetChecked(AmrDb.SendSettings.SendEnchants)
67 tab.enchantsCheckbox:SetScript("OnClick", function () AmrSendSettings.SendEnchants = tab.enchantsCheckbox:GetChecked() end) 67 tab.enchantsCheckbox:SetScript("OnClick", function () AmrDb.SendSettings.SendEnchants = tab.enchantsCheckbox:GetChecked() end)
68 tab.enchantsCheckbox:SetPoint("TOPLEFT", tab.sendButton, "TOPLEFT", 0, 50) 68 tab.enchantsCheckbox:SetPoint("TOPLEFT", tab.sendButton, "TOPLEFT", 0, 50)
69 local text2 = getglobal(tab.enchantsCheckbox:GetName() .. 'Text') 69 local text2 = getglobal(tab.enchantsCheckbox:GetName() .. 'Text')
70 text2:SetFontObject("GameFontHighlightLarge") 70 text2:SetFontObject("GameFontHighlightLarge")
71 text2:SetText(L.AMR_SHOPPINGLISTTAB_ENCHANTS) 71 text2:SetText(L.AMR_SHOPPINGLISTTAB_ENCHANTS)
72 text2:SetWidth(150) 72 text2:SetWidth(150)
74 74
75 75
76 76
77 tab.gemsCheckbox = CreateFrame("CheckButton", "AmrGemsCheckbox", tab.shoppingPanel, "ChatConfigCheckButtonTemplate"); 77 tab.gemsCheckbox = CreateFrame("CheckButton", "AmrGemsCheckbox", tab.shoppingPanel, "ChatConfigCheckButtonTemplate");
78 tab.gemsCheckbox:SetPoint("TOPLEFT", tab.sendButton, "TOPLEFT", 0, 75) 78 tab.gemsCheckbox:SetPoint("TOPLEFT", tab.sendButton, "TOPLEFT", 0, 75)
79 tab.gemsCheckbox:SetChecked(AmrSendSettings.SendGems) 79 tab.gemsCheckbox:SetChecked(AmrDb.SendSettings.SendGems)
80 tab.gemsCheckbox:SetScript("OnClick", function () AmrSendSettings.SendGems = tab.gemsCheckbox:GetChecked() end) 80 tab.gemsCheckbox:SetScript("OnClick", function () AmrDb.SendSettings.SendGems = tab.gemsCheckbox:GetChecked() end)
81 local text = getglobal(tab.gemsCheckbox:GetName() .. 'Text') 81 local text = getglobal(tab.gemsCheckbox:GetName() .. 'Text')
82 text:SetFontObject("GameFontHighlightLarge") 82 text:SetFontObject("GameFontHighlightLarge")
83 text:SetText(L.AMR_SHOPPINGLISTTAB_GEMS) 83 text:SetText(L.AMR_SHOPPINGLISTTAB_GEMS)
84 text:SetWidth(150) 84 text:SetWidth(150)
85 text:SetPoint("TOPLEFT", tab.gemsCheckbox, "TOPRIGHT", 2, -4) 85 text:SetPoint("TOPLEFT", tab.gemsCheckbox, "TOPRIGHT", 2, -4)
165 165
166 -- Create the dropdown, and configure its appearance 166 -- Create the dropdown, and configure its appearance
167 tab.dropDown = CreateFrame("FRAME", "AmrSendType", tab.shoppingPanel, "UIDropDownMenuTemplate") 167 tab.dropDown = CreateFrame("FRAME", "AmrSendType", tab.shoppingPanel, "UIDropDownMenuTemplate")
168 tab.dropDown:SetPoint("TOPLEFT", tab.sendMessage3, "TOPRIGHT", 0, 5) 168 tab.dropDown:SetPoint("TOPLEFT", tab.sendMessage3, "TOPRIGHT", 0, 5)
169 UIDropDownMenu_SetWidth(tab.dropDown, 140) 169 UIDropDownMenu_SetWidth(tab.dropDown, 140)
170 UIDropDownMenu_SetText(tab.dropDown, AmrSendSettings.SendToType) 170 UIDropDownMenu_SetText(tab.dropDown, AmrDb.SendSettings.SendToType)
171 171
172 local text = getglobal(tab.dropDown:GetName() .. 'Text') 172 local text = getglobal(tab.dropDown:GetName() .. 'Text')
173 text:SetFontObject("GameFontHighlightLarge") 173 text:SetFontObject("GameFontHighlightLarge")
174 174
175 local AddButton = function(list, optionText) 175 local AddButton = function(list, optionText)
176 local info = UIDropDownMenu_CreateInfo() 176 local info = UIDropDownMenu_CreateInfo()
177 info.justifyH = "RIGHT" 177 info.justifyH = "RIGHT"
178 info.text = optionText 178 info.text = optionText
179 info.checked = AmrSendSettings.SendToType == optionText 179 info.checked = AmrDb.SendSettings.SendToType == optionText
180 info.arg1 = optionText 180 info.arg1 = optionText
181 info.func = list.SetValue 181 info.func = list.SetValue
182 info.owner = list 182 info.owner = list
183 info.fontObject = "GameFontHighlightLarge" 183 info.fontObject = "GameFontHighlightLarge"
184 info.minWidth = 140 184 info.minWidth = 140
194 UIDropDownMenu_AddButton(AddButton(self, L.AMR_SHOPPINGLISTTAB_DROPDOWN_CHANNEL)) 194 UIDropDownMenu_AddButton(AddButton(self, L.AMR_SHOPPINGLISTTAB_DROPDOWN_CHANNEL))
195 UIDropDownMenu_AddButton(AddButton(self, L.AMR_SHOPPINGLISTTAB_DROPDOWN_MAIL)) 195 UIDropDownMenu_AddButton(AddButton(self, L.AMR_SHOPPINGLISTTAB_DROPDOWN_MAIL))
196 end) 196 end)
197 197
198 function tab.dropDown:SetValue(newValue) 198 function tab.dropDown:SetValue(newValue)
199 AmrSendSettings.SendToType = newValue 199 AmrDb.SendSettings.SendToType = newValue
200 -- Update the text; if we merely wanted it to display newValue, we would not need to do this 200 -- Update the text; if we merely wanted it to display newValue, we would not need to do this
201 UIDropDownMenu_SetText(tab.dropDown, AmrSendSettings.SendToType) 201 UIDropDownMenu_SetText(tab.dropDown, AmrDb.SendSettings.SendToType)
202 -- Because this is called from a sub-menu, only that menu level is closed by default. 202 -- Because this is called from a sub-menu, only that menu level is closed by default.
203 -- Close the entire menu with this next call 203 -- Close the entire menu with this next call
204 CloseDropDownMenus() 204 CloseDropDownMenus()
205 end 205 end
206 206
207 tab.sendTo = CreateFrame("EditBox", "AmrSendTo", tab.shoppingPanel, "InputBoxTemplate" ) 207 tab.sendTo = CreateFrame("EditBox", "AmrSendTo", tab.shoppingPanel, "InputBoxTemplate" )
208 tab.sendTo:SetPoint("TOPLEFT", tab.dropDown, "TOPRIGHT", 0, 0) 208 tab.sendTo:SetPoint("TOPLEFT", tab.dropDown, "TOPRIGHT", 0, 0)
209 tab.sendTo:SetPoint("RIGHT", 0, 0) 209 tab.sendTo:SetPoint("RIGHT", 0, 0)
210 tab.sendTo:SetHeight(30) 210 tab.sendTo:SetHeight(30)
211 tab.sendTo:SetText(AmrSendSettings.SendTo or "") 211 tab.sendTo:SetText(AmrDb.SendSettings.SendTo or "")
212 tab.sendTo:SetFontObject("GameFontHighlightLarge") 212 tab.sendTo:SetFontObject("GameFontHighlightLarge")
213 tab.sendTo:SetAutoFocus(false) 213 tab.sendTo:SetAutoFocus(false)
214 tab.sendTo:SetScript("OnChar", function() 214 tab.sendTo:SetScript("OnChar", function()
215 AmrSendSettings.SendTo = tab.sendTo:GetText() 215 AmrDb.SendSettings.SendTo = tab.sendTo:GetText()
216 end) 216 end)
217 217
218 tab.messageQueue = {} 218 tab.messageQueue = {}
219 return tab 219 return tab
220 end 220 end
254 -- make a link for the optimized gem 254 -- make a link for the optimized gem
255 gemLink = select(2, GetItemInfo(gemInfo.id)) 255 gemLink = select(2, GetItemInfo(gemInfo.id))
256 256
257 -- set the link (tooltip + icon) 257 -- set the link (tooltip + icon)
258 gemIcon:SetItemLink(gemLink) 258 gemIcon:SetItemLink(gemLink)
259 gemIcon:SetGemColor(gemInfo.color) 259 --gemIcon:SetGemColor(gemInfo.color)
260 gemIcon:SetGemColor('Prismatic')
260 261
261 -- if we didn't get one, its because WoW is slow 262 -- if we didn't get one, its because WoW is slow
262 if not gemLink and gemInfo.id then 263 if not gemLink and gemInfo.id then
263 -- when WoW finally returns the link, set the icon / tooltip 264 -- when WoW finally returns the link, set the icon / tooltip
264 AskMrRobot.RegisterItemInfoCallback(gemInfo.id, function(name, link) 265 AskMrRobot.RegisterItemInfoCallback(gemInfo.id, function(name, link)
550 551
551 return count > 0 552 return count > 0
552 end 553 end
553 554
554 function AskMrRobot.ShoppingListTab:CalculateItems() 555 function AskMrRobot.ShoppingListTab:CalculateItems()
555 -- build a map of missing gem-ids -> {id, color, enchantid, count, total} 556 -- build a map of missing gem-enchant-ids -> {id, enchantid, count, total}
556 local gemList = {} 557 local gemList = {}
557 for slotNum, badGems in pairs(AskMrRobot.itemDiffs.gems) do 558
558 --badGems: {current: array of enchant ids, optimized: (array of {id, color, enchantId}) 559 -- for each piece of gear that needs at least 1 gem changed
559 for i = 1, #badGems.optimized do 560 for _, badGems in pairs(AskMrRobot.ComparisonResult.gems) do
560 if badGems.badGems[i] then 561 -- for each specified gem
561 local goodGem = badGems.optimized[i] 562 for g = 1, #badGems.optimized do
562 if goodGem.id ~= 0 then 563 local goodGemEnchantId = badGems.optimized[g]
563 local gem = gemList[goodGem.id] 564 -- if AMR says to optimized this gem AND it does *NOT* match matches the current gem
564 if gem == nil then 565 if goodGemEnchantId ~= 0 and not AskMrRobot.AreGemsCompatible(goodGemEnchantId, badGems.current[g]) then
565 gemList[goodGem.id] = {id = goodGem.id, enchantId = goodGem.enchantId, color = goodGem.color, count = 0, total = 1} 566 -- see if this gem is in our list of gems to optimize
566 else 567 local gem = gemList[goodGemEnchantId]
567 gem.total = gem.total + 1 568 if gem == nil then
568 end 569 -- if not, add it
570 gemList[goodGemEnchantId] = {id = AskMrRobot.ExtraGemData[goodGemEnchantId].id, enchantId = goodGemEnchantId, count = 0, total = 1, compatibleGemIds = AskMrRobot.ExtraGemData[goodGemEnchantId].identicalItemGroup}
571 else
572 -- if so, increase the total requested for this
573 gem.total = gem.total + 1
569 end 574 end
570 end 575 end
571 end 576 end
572 end 577 end
573 578
574 local enchantList = {} 579 local enchantList = {}
575 for slot, enchantData in AskMrRobot.sortSlots(AskMrRobot.itemDiffs.enchants) do 580 for slot, enchantData in AskMrRobot.sortSlots(AskMrRobot.ComparisonResult.enchants) do
576 local id = AskMrRobot.getEnchantItemId(enchantData.optimized) or enchantData.optimized 581 local extraData = AskMrRobot.ExtraEnchantData[enchantData.optimized]
582 local id = extraData and extraData.itemId or enchantData.optimized
577 local qty = enchantList[id] 583 local qty = enchantList[id]
578 if qty then 584 if qty then
579 qty.total = qty.total + 1 585 qty.total = qty.total + 1
580 else 586 else
581 qty = { count = 0, total = 1, optimized = enchantData.optimized } 587 qty = { count = 0, total = 1, optimized = enchantData.optimized }
582 enchantList[id] = qty 588 enchantList[id] = qty
583 end 589 end
584 end 590 end
585 591
586 local enchantMaterials = {} 592 local enchantMaterials = {}
587 for slot, enchantData in pairs(AskMrRobot.itemDiffs.enchants) do 593 for slot, enchantData in pairs(AskMrRobot.ComparisonResult.enchants) do
588 AskMrRobot.addEnchantMaterials(enchantMaterials, enchantData.optimized) 594 local extraData = AskMrRobot.ExtraEnchantData[enchantData.optimized]
589 end 595 if extraData and extraData.materials then
590 596 local itemId
591 --substract any inventory we already have in the bank 597 local count
592 for i = 1, #AmrBankItemsAndCounts do 598 for itemId, count in pairs(extraData.materials) do
593 local itemId = AskMrRobot.getItemIdFromLink(AmrBankItemsAndCounts[i].link) 599 if enchantMaterials[itemId] then
594 if itemId then 600 enchantMaterials[itemId].total = enchantMaterials[itemId].total + count
595 local gem = gemList[itemId] 601 else
596 if gem then 602 enchantMaterials[itemId] = { count = 0, total = count }
597 gem.count = gem.count + AmrBankItemsAndCounts[i].count
598 else
599 local alternateGemId = AskMrRobot.gemDuplicates[itemId]
600 if alternateGemId then
601 gem = gemList[alternateGemId]
602 if gem then
603 gem.count = gem.count + AmrBankItemsAndCounts[i].count
604 end
605 end 603 end
606 end 604 end
607 local material = enchantMaterials[itemId] 605 end
608 if material then 606
609 material.count = material.count + AmrBankItemsAndCounts[i].count 607 end
610 end 608
611 local enchant = enchantList[itemId] 609 local bagItemsWithCounts = {}
612 if enchant then 610 -- copy the bank items into a new table so we don't alter them
613 enchant.count = enchant.count + AmrBankItemsAndCounts[i].count 611 if (AmrDb.BankItemsAndCounts) then
614 end 612 for id, count in pairs(AmrDb.BankItemsAndCounts) do
615 end 613 bagItemsWithCounts[id] = count
616 end 614 end
617 615 end
618 local _ , bagItemsWithCount = AskMrRobot.ScanBags() 616
619 617 -- add the items from the players bags
620 --substract any inventory we already have in bags 618 AskMrRobot.ScanBags(bagItemsWithCounts)
621 for i = 1, #bagItemsWithCount do 619
622 local itemId = AskMrRobot.getItemIdFromLink(bagItemsWithCount[i].link) 620 --substract any inventory we already have in bags/bank
623 if itemId then 621 for itemId, count in pairs(bagItemsWithCounts) do
624 local gem = gemList[itemId] 622 for _, gem in pairs(gemList) do
625 if gem then 623 if gem.compatibleGemIds[itemId] and gem.count < gem.total then
626 gem.count = gem.count + bagItemsWithCount[i].count 624 local needed = gem.total - gem.count
627 else 625 if count > needed then
628 local alternateGemId = AskMrRobot.gemDuplicates[itemId] 626 gem.count = gem.total
629 if alternateGemId then 627 -- only consume the number needed (subtract in case this is compatible with a different gem)
630 gem = gemList[alternateGemId] 628 count = count - needed
631 if gem then 629 else
632 gem.count = gem.count + bagItemsWithCount[i].count 630 gem.count = gem.count + count
633 end 631 count = 0
634 end 632 end
635 end 633 end
636 local material = enchantMaterials[itemId] 634 end
637 if material then 635 local material = enchantMaterials[itemId]
638 material.count = material.count + bagItemsWithCount[i].count 636 if material then
639 end 637 material.count = material.count + count
640 local enchant = enchantList[itemId] 638 end
641 if enchant then 639 local enchant = enchantList[itemId]
642 enchant.count = enchant.count + bagItemsWithCount[i].count 640 if enchant then
643 end 641 enchant.count = enchant.count + count
644 end 642 end
645 end 643 end
646 644
647 return gemList, enchantList, enchantMaterials 645 return gemList, enchantList, enchantMaterials
648 end 646 end
781 779
782 local message = L.AMR_SHOPPINGLISTTAB_MAIL_ROBOT_MESSAGE 780 local message = L.AMR_SHOPPINGLISTTAB_MAIL_ROBOT_MESSAGE
783 781
784 local gemList, enchantList, enchantMaterials = self:CalculateItems() 782 local gemList, enchantList, enchantMaterials = self:CalculateItems()
785 783
786 if AmrSendSettings.SendGems then 784 if AmrDb.SendSettings.SendGems then
787 for k,v in pairs(gemList) do 785 for k,v in pairs(gemList) do
788 --exclude jewelcrafter gems 786 --exclude jewelcrafter gems
789 if not AskMrRobot.JewelcrafterGems[k] then 787 --if not AskMrRobot.JewelcrafterGems[k] then
790 local needed = v.total - v.count 788 local needed = v.total - v.count
791 if needed > 0 then 789 if needed > 0 then
792 local itemName = GetItemInfo(k) 790 local itemName = GetItemInfo(v.id)
793 if itemName then 791 if itemName then
794 message = message .. "\n" .. needed .. "x " .. itemName 792 message = message .. "\n" .. needed .. "x " .. itemName
795 end 793 end
796 end 794 end
797 end 795 --end
798 end 796 end
799 end 797 end
800 798
801 if AmrSendSettings.SendEnchants then 799 if AmrDb.SendSettings.SendEnchants then
802 for k,v in pairs(enchantList) do 800 for k,v in pairs(enchantList) do
803 local needed = v.total - v.count 801 local needed = v.total - v.count
804 if needed > 0 then 802 if needed > 0 then
805 local itemName = GetItemInfo(k) 803 local itemName = GetItemInfo(k)
806 if itemName then 804 if itemName then
808 end 806 end
809 end 807 end
810 end 808 end
811 end 809 end
812 810
813 if AmrSendSettings.SendEnchantMaterials then 811 if AmrDb.SendSettings.SendEnchantMaterials then
814 for k,v in pairs(enchantMaterials) do 812 for k,v in pairs(enchantMaterials) do
815 local needed = v.total - v.count 813 local needed = v.total - v.count
816 if needed > 0 then 814 if needed > 0 then
817 local itemName = GetItemInfo(k) 815 local itemName = GetItemInfo(k)
818 if itemName then 816 if itemName then
821 end 819 end
822 end 820 end
823 end 821 end
824 822
825 MailFrameTab_OnClick(nil, 2) 823 MailFrameTab_OnClick(nil, 2)
826 if AmrSendSettings.SendGems then 824 if AmrDb.SendSettings.SendGems then
827 if AmrSendSettings.SendEnchants then 825 if AmrDb.SendSettings.SendEnchants then
828 SendMailSubjectEditBox:SetText(L.AMR_SHOPPINGLISTTAB_MAIL_SUBJECT_GE) 826 SendMailSubjectEditBox:SetText(L.AMR_SHOPPINGLISTTAB_MAIL_SUBJECT_GE)
829 else 827 else
830 SendMailSubjectEditBox:SetText(L.AMR_SHOPPINGLISTTAB_MAIL_SUBJECT_G) 828 SendMailSubjectEditBox:SetText(L.AMR_SHOPPINGLISTTAB_MAIL_SUBJECT_G)
831 end 829 end
832 else 830 else
833 SendMailSubjectEditBox:SetText(L.AMR_SHOPPINGLISTTAB_MAIL_SUBJECT_E) 831 SendMailSubjectEditBox:SetText(L.AMR_SHOPPINGLISTTAB_MAIL_SUBJECT_E)
834 end 832 end
835 SendMailNameEditBox:SetText(AmrSendSettings.SendTo) 833 SendMailNameEditBox:SetText(AmrDb.SendSettings.SendTo)
836 SendMailBodyEditBox:SetText(message) 834 SendMailBodyEditBox:SetText(message)
837 end 835 end
838 836
839 function AskMrRobot.ShoppingListTab:Send() 837 function AskMrRobot.ShoppingListTab:Send()
840 local chatType = nil 838 local chatType = nil
841 if AmrSendSettings.SendToType == L.AMR_SHOPPINGLISTTAB_DROPDOWN_PARTY then 839 if AmrDb.SendSettings.SendToType == L.AMR_SHOPPINGLISTTAB_DROPDOWN_PARTY then
842 chatType = "PARTY" 840 chatType = "PARTY"
843 elseif AmrSendSettings.SendToType == L.AMR_SHOPPINGLISTTAB_DROPDOWN_GUILD then 841 elseif AmrDb.SendSettings.SendToType == L.AMR_SHOPPINGLISTTAB_DROPDOWN_GUILD then
844 chatType = "GUILD" 842 chatType = "GUILD"
845 elseif AmrSendSettings.SendToType == L.AMR_SHOPPINGLISTTAB_DROPDOWN_RAID then 843 elseif AmrDb.SendSettings.SendToType == L.AMR_SHOPPINGLISTTAB_DROPDOWN_RAID then
846 chatType = "RAID" 844 chatType = "RAID"
847 elseif AmrSendSettings.SendToType == L.AMR_SHOPPINGLISTTAB_DROPDOWN_CHANNEL then 845 elseif AmrDb.SendSettings.SendToType == L.AMR_SHOPPINGLISTTAB_DROPDOWN_CHANNEL then
848 chatType = "CHANNEL" 846 chatType = "CHANNEL"
849 elseif AmrSendSettings.SendToType == L.AMR_SHOPPINGLISTTAB_DROPDOWN_MAIL then 847 elseif AmrDb.SendSettings.SendToType == L.AMR_SHOPPINGLISTTAB_DROPDOWN_MAIL then
850 self:sendMail() 848 self:sendMail()
851 return 849 return
852 else 850 else
853 chatType = "WHISPER" 851 chatType = "WHISPER"
854 end 852 end
858 856
859 857
860 local gemList, enchantList, enchantMaterials = self:CalculateItems() 858 local gemList, enchantList, enchantMaterials = self:CalculateItems()
861 859
862 local items = {} 860 local items = {}
863 if AmrSendSettings.SendGems then 861 if AmrDb.SendSettings.SendGems then
864 for k,v in pairs(gemList) do 862 for k,v in pairs(gemList) do
865 if not AskMrRobot.JewelcrafterGems[k] then 863 --if not AskMrRobot.JewelcrafterGems[k] then
866 local needed = v.total - v.count 864 local needed = v.total - v.count
867 if needed > 0 then 865 if needed > 0 then
868 tinsert(items, {id = k, needed = needed}) 866 tinsert(items, {id = v.id, needed = needed})
869 end 867 end
870 end 868 --end
871 end 869 end
872 end 870 end
873 871
874 if AmrSendSettings.SendEnchants then 872 if AmrDb.SendSettings.SendEnchants then
875 for k,v in pairs(enchantList) do 873 for k,v in pairs(enchantList) do
876 local needed = v.total - v.count 874 local needed = v.total - v.count
877 if needed > 0 then 875 if needed > 0 then
878 tinsert(items, {id = k, needed = needed}) 876 tinsert(items, {id = k, needed = needed})
879 end 877 end
880 end 878 end
881 end 879 end
882 880
883 if AmrSendSettings.SendEnchantMaterials then 881 if AmrDb.SendSettings.SendEnchantMaterials then
884 for k,v in pairs(enchantMaterials) do 882 for k,v in pairs(enchantMaterials) do
885 local needed = v.total - v.count 883 local needed = v.total - v.count
886 if needed > 0 then 884 if needed > 0 then
887 tinsert(items, {id = k, needed = needed}) 885 tinsert(items, {id = k, needed = needed})
888 end 886 end
893 local _, link = GetItemInfo(entry.id) 891 local _, link = GetItemInfo(entry.id)
894 if link then 892 if link then
895 message = message .. " " .. entry.needed .. "x " .. link 893 message = message .. " " .. entry.needed .. "x " .. link
896 count = count + 1 894 count = count + 1
897 if count == 2 then 895 if count == 2 then
898 tinsert(self.messageQueue, {message = message, chatType = chatType, chatChannel = AmrSendSettings.SendTo}) 896 tinsert(self.messageQueue, {message = message, chatType = chatType, chatChannel = AmrDb.SendSettings.SendTo})
899 count = 0 897 count = 0
900 message = L.AMR_SHOPPINGLISTTAB_CHAT_ROBOT_MESSAGE 898 message = L.AMR_SHOPPINGLISTTAB_CHAT_ROBOT_MESSAGE
901 end 899 end
902 end 900 end
903 end 901 end
904 902
905 if count > 0 then 903 if count > 0 then
906 tinsert(self.messageQueue, {message = message, chatType = chatType, chatChannel = AmrSendSettings.SendTo}) 904 tinsert(self.messageQueue, {message = message, chatType = chatType, chatChannel = AmrDb.SendSettings.SendTo})
907 end 905 end
908 906
909 self:SendNextMessage() 907 self:SendNextMessage()
910 end 908 end
911 909