changeset 45:1851d0fd18fa v15

fixed an issue with shopping tab enchant links not working on AH
author yellowfive
date Sat, 01 Nov 2014 22:51:36 -0700
parents 8e853e90af9c
children d28e38e5240f
files AskMrRobot.lua AskMrRobot.toc ui/ShoppingListTab.lua
diffstat 3 files changed, 33 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/AskMrRobot.lua	Fri Oct 24 13:38:31 2014 -0700
+++ b/AskMrRobot.lua	Sat Nov 01 22:51:36 2014 -0700
@@ -780,7 +780,7 @@
 -- the data that was last imported
 AskMrRobot.ImportData = nil       -- keyed by slot id
 
-local MIN_IMPORT_VERSION = 2
+local MIN_IMPORT_VERSION = 13
 
 --
 -- Import a character, returning nil on success, otherwise an error message, import result stored in AskMrRobot.ImportData
--- a/AskMrRobot.toc	Fri Oct 24 13:38:31 2014 -0700
+++ b/AskMrRobot.toc	Sat Nov 01 22:51:36 2014 -0700
@@ -1,7 +1,7 @@
 ## Interface: 60000
 ## Title: Ask Mr. Robot
 ## Author: Team Robot, Inc.
-## Version: 14
+## Version: 15
 ## Notes: Exports/Imports data to/from askmrrobot.com.
 ## URL: www.askmrrobot.com
 ## DefaultState: Enabled
--- a/ui/ShoppingListTab.lua	Fri Oct 24 13:38:31 2014 -0700
+++ b/ui/ShoppingListTab.lua	Sat Nov 01 22:51:36 2014 -0700
@@ -24,6 +24,7 @@
 	tab:RegisterEvent("AUCTION_HOUSE_SHOW")
 	tab:RegisterEvent("MAIL_SHOW")
 	tab:RegisterEvent("MAIL_CLOSED")
+	tab:RegisterEvent("GET_ITEM_INFO_RECEIVED")
 
 	tab.isAuctionHouseVisible = false
 
@@ -216,6 +217,8 @@
 	end)
 
 	tab.messageQueue = {}
+
+	tab.itemNames = {}
 	return tab
 end
 
@@ -584,7 +587,7 @@
 		if qty then
 			qty.total = qty.total + 1
 		else
-			qty = { count = 0, total = 1, optimized = enchantData.optimized }
+			qty = { count = 0, total = 1, optimized = enchantData.optimized, itemId = extraData and extraData.itemId }
 			enchantList[id] = qty
 		end
 	end
@@ -680,9 +683,16 @@
 		self.enchantsHeader:SetPoint("TOPLEFT", self.scrollParent, "TOPLEFT", 0, 0)
 	end
 
+	self.enchantNames = {}
 	row = 1
 	for slot, enchant in AskMrRobot.spairs(enchantList) do
 		self:SetEnchantIcon(row, enchant.optimized)
+		local row2 = row
+		self.enchantIcons[row2].itemName = nil
+		self:GetItemName(enchant.itemId, function(name) 
+			self.enchantIcons[row2].itemName = name 
+			self.enchantIcons[row2].itemText:SetText(name)
+		end)
 		self:SetEnchantQuantity(row, enchant.count, enchant.total)
 		lastControl = self.enchantIcons[row]
 		row = row + 1
@@ -747,6 +757,26 @@
 	end
 end
 
+function AskMrRobot.ShoppingListTab:GetItemName(itemId, func)
+	local name = GetItemInfo(itemId)
+	if name then
+		func(name)
+	else
+		tinsert(self.itemNames, { itemId = itemId, func = func })
+	end
+end
+
+function AskMrRobot.ShoppingListTab:On_GET_ITEM_INFO_RECEIVED()
+	for i = 1, #self.itemNames do
+		local name = GetItemInfo(self.itemNames[i].itemId)
+	    if name then
+	    	self.itemNames[i].func(name)
+	    	tremove(self.itemNames, i)
+	    	i = i - 1
+	    end
+	end
+	self.itemNames = itemNames
+end
 
 function AskMrRobot.ShoppingListTab:OnEvent(frame, event, ...)
 	local handler = self["On_" .. event]