Quantcast

-Fixed an issue that would sometimes cause the LibItemSearch library to produce an error.

Xruptor [01-06-11 - 13:16]
-Fixed an issue that would sometimes cause the LibItemSearch library to produce an error.
-LibItemSearch library has been updated to a new version, now support tooltip searching.
-You can now search for specific words in a tooltip by using the command (tt:). example:  tt:companion
Filename
BagSync.toc
BagSync_Search.lua
libs/LibItemSearch-1.0.lua
diff --git a/BagSync.toc b/BagSync.toc
index edb7556..029e92d 100644
--- a/BagSync.toc
+++ b/BagSync.toc
@@ -2,7 +2,7 @@
 ## Title: BagSync
 ## Notes: BagSync tracks your characters items and displays it within tooltips.
 ## Author: Xruptor
-## Version: 5.4.1
+## Version: 5.5
 ## SavedVariables: BagSyncDB, BagSyncOpt, BagSyncGUILD_DB, BagSyncTOKEN_DB

 localization\localization.lua
diff --git a/BagSync_Search.lua b/BagSync_Search.lua
index 8b3e800..8c9e3f3 100644
--- a/BagSync_Search.lua
+++ b/BagSync_Search.lua
@@ -214,11 +214,11 @@ function bgSearch:DoSearch()
 			for q, r in pairs(BagSyncDB[currentRealm][k]) do
 				local dblink, dbcount = strsplit(',', r)
 				if dblink then
-					local dName, dLinkD, dRarity = GetItemInfo(dblink)
-					if dName then
+					local dName, dItemLink, dRarity = GetItemInfo(dblink)
+					if dName and dItemLink then
 						--we found a match
-						if not tempList[dblink] and ItemSearch:Find(dblink, searchStr) then
-							table.insert(searchTable, { name=dName, link=dLinkD, rarity=dRarity } )
+						if not tempList[dblink] and ItemSearch:Find(dItemLink, searchStr) then
+							table.insert(searchTable, { name=dName, link=dItemLink, rarity=dRarity } )
 							tempList[dblink] = dName
 							count = count + 1
 						end
@@ -237,11 +237,11 @@ function bgSearch:DoSearch()
 						for q, r in pairs(BagSyncGUILD_DB[currentRealm][guildN]) do
 							local dblink, dbcount = strsplit(',', r)
 							if dblink then
-								local dName, dLinkD, dRarity = GetItemInfo(dblink)
+								local dName, dItemLink, dRarity = GetItemInfo(dblink)
 								if dName then
 									--we found a match
-									if not tempList[dblink] and ItemSearch:Find(dblink, searchStr) then
-										table.insert(searchTable, { name=dName, link=dLinkD, rarity=dRarity } )
+									if not tempList[dblink] and ItemSearch:Find(dItemLink, searchStr) then
+										table.insert(searchTable, { name=dName, link=dItemLink, rarity=dRarity } )
 										tempList[dblink] = dName
 										count = count + 1
 									end
diff --git a/libs/LibItemSearch-1.0.lua b/libs/LibItemSearch-1.0.lua
index e7f52a6..85cce6f 100644
--- a/libs/LibItemSearch-1.0.lua
+++ b/libs/LibItemSearch-1.0.lua
@@ -18,7 +18,7 @@
 	I kindof half want to make a full parser for this
 --]]

-local MAJOR, MINOR = "LibItemSearch-1.0", 2
+local MAJOR, MINOR = "LibItemSearch-1.0", 3
 local ItemSearch = LibStub:NewLibrary(MAJOR, MINOR)
 if not ItemSearch then return end

@@ -317,6 +317,33 @@ ItemSearch:RegisterTypedSearch{
 	}
 }

+ItemSearch:RegisterTypedSearch{
+	id = 'tooltipDesc',
+
+	isSearch = function(self, search)
+		return search and search:match('^tt:(.+)$')
+	end,
+
+	findItem = function(self, itemLink, search)
+		--no match?, pull in the resut from tooltip parsing
+		tooltipScanner:SetOwner(UIParent, 'ANCHOR_NONE')
+		tooltipScanner:SetHyperlink(itemLink)
+
+		local i = 1
+		while i <= tooltipScanner:NumLines() do
+			local text =  _G[tooltipScanner:GetName() .. 'TextLeft' .. i]:GetText():lower()
+			if text and text:match(search) then
+				tooltipScanner:Hide()
+				return true
+			end
+			i = i + 1
+		end
+
+		tooltipScanner:Hide()
+		return false
+	end,
+}
+

 --[[ equipment set search ]]--