- Fixed LibStub typo

Yaron Kfir [06-16-14 - 21:20]
- Fixed LibStub typo
- Added pricing info on item tooltip when item link is clicked in chat window
Filename
Changelog
PriceTracker.lua
PriceTracker.txt
diff --git a/Changelog b/Changelog
index 6a8eca2..871ba4a 100644
--- a/Changelog
+++ b/Changelog
@@ -1,5 +1,9 @@
 Changelog

+v1.4
+ - Fixed LibStub typo
+ - Added pricing info on item tooltip when item link is clicked in chat window
+
 v1.3
  - Added option to view prices from all guilds or a specific guild

diff --git a/PriceTracker.lua b/PriceTracker.lua
index b2bf987..b72be77 100644
--- a/PriceTracker.lua
+++ b/PriceTracker.lua
@@ -25,9 +25,15 @@ function PriceTracker:OnLoad(eventCode, addOnName)
 	EVENT_MANAGER:RegisterForEvent("OnSearchResultsReceived", EVENT_TRADING_HOUSE_SEARCH_RESULTS_RECEIVED, function(...) self:OnSearchResultsReceived(...) end)
 	EVENT_MANAGER:RegisterForEvent("OnTradingHouseClosed", EVENT_CLOSE_TRADING_HOUSE, function(...) self:OnTradingHouseClosed(...) end)

+	LINK_HANDLER:RegisterCallback(LINK_HANDLER.LINK_CLICKED_EVENT, PriceTracker.OnLinkClicked, self)
+
 	ZO_PreHookHandler(ItemTooltip, "OnUpdate", function() self:OnUpdateTooltip(moc(), ItemTooltip) end)
 	ZO_PreHookHandler(ItemTooltip, "OnHide", function() self:OnHideTooltip(ItemTooltip) end)

+	ZO_PreHookHandler(PopupTooltip, "OnUpdate", function() self:OnUpdateTooltip(self.clickedItem, PopupTooltip) end)
+	ZO_PreHookHandler(PopupTooltip, "OnHide", function() self:OnHideTooltip(PopupTooltip) end)
+
+
 	PriceTracker.enchantingTable:OnLoad(eventCode, addOnName)

 	SLASH_COMMANDS["/pt"] = function(...) self:CommandHandler(...) end
@@ -135,6 +141,7 @@ end

 function PriceTracker:OnHideTooltip(tooltip)
 	self.selectedItem[tooltip] = nil
+	self.clickedItem = nil
 end

 function PriceTracker:OnScanPrices()
@@ -176,6 +183,22 @@ function PriceTracker:OnTradingHouseClosed()
 	self.button:SetEnabled(true)
 end

+function PriceTracker:OnLinkClicked(rawLink, mouseButton, linkText, color, linkType, itemId, ...)
+	if linkType ~= "item" then return end
+
+	local _, sellPrice, _, _, _ = GetItemLinkInfo(rawLink)
+	local item = {
+		dataEntry = {
+			data = {
+				name = self:NormalizeName(string.sub(linkText, 2, #linkText - 1)),
+				stackCount = 1,
+				purchasePrice = sellPrice
+			}
+		}
+	}
+	self.clickedItem = item
+end
+
 function PriceTracker:AddItem(icon, itemName, quality, stackCount, sellerName, timeRemaining, purchasePrice)
 	if not purchasePrice or not stackCount then return end

diff --git a/PriceTracker.txt b/PriceTracker.txt
index bdf4c17..57460d2 100644
--- a/PriceTracker.txt
+++ b/PriceTracker.txt
@@ -1,6 +1,6 @@
 ## Title: PriceTracker
 ## Author: Barvazon
-## Version: 1.2
+## Version: 1.4
 ## SavedVariables: PriceTrackerSettings
 ## APIVersion: 100004
 ## OptionalDependsOn: LibAddonMenu-1.0
@@ -10,5 +10,5 @@ PriceTracker.lua
 PriceTrackerMenu.lua
 PriceTrackerEnchantingTable.lua
 MathUtils.lua
-lib/Libtub/LibStub.lua
+lib/LibStub/LibStub.lua
 lib/LibAddonMenu-1.0/LibAddonMenu-1.0.lua