Quantcast

-Added throttling to remove lag when mousing over items quickly in bags.

Xruptor [07-07-10 - 16:01]
-Added throttling to remove lag when mousing over items quickly in bags.
-Added an option to toggle throttling. (/bgs throttle)
-New throttling feature improves on framerate :)
Filename
BagSync.lua
BagSync.toc
localization/localization.lua
diff --git a/BagSync.lua b/BagSync.lua
index 8697ec0..6a342aa 100644
--- a/BagSync.lua
+++ b/BagSync.lua
@@ -158,6 +158,15 @@ function BagSync:PLAYER_LOGIN()
 					print("|cFFFF0000BagSync: "..BAGSYNC_SLASH_CMD8.." "..BAGSYNC_SWITCH_ON)
 				end
 				return true
+			elseif c and c:lower() == BAGSYNC_SLASH_CMD9 then
+				if BagSyncOpt.enableThrottle then
+					BagSyncOpt.enableThrottle = false
+					print("|cFFFF0000BagSync: "..BAGSYNC_SLASH_CMD9.." "..BAGSYNC_SWITCH_OFF)
+				else
+					BagSyncOpt.enableThrottle = true
+					print("|cFFFF0000BagSync: "..BAGSYNC_SLASH_CMD9.." "..BAGSYNC_SWITCH_ON)
+				end
+				return true
 			elseif c and c:lower() ~= "" then
 				--do an item search
 				if BagSync_SearchFrame then
@@ -170,17 +179,12 @@ function BagSync:PLAYER_LOGIN()
 		end

 		DEFAULT_CHAT_FRAME:AddMessage("BAGSYNC")
-		DEFAULT_CHAT_FRAME:AddMessage(BAGSYNC_SLASH1)
-		DEFAULT_CHAT_FRAME:AddMessage(BAGSYNC_SLASH2)
-		DEFAULT_CHAT_FRAME:AddMessage(BAGSYNC_SLASH3)
-		DEFAULT_CHAT_FRAME:AddMessage(BAGSYNC_SLASH4)
-		DEFAULT_CHAT_FRAME:AddMessage(BAGSYNC_SLASH5)
-		DEFAULT_CHAT_FRAME:AddMessage(BAGSYNC_SLASH6)
-		DEFAULT_CHAT_FRAME:AddMessage(BAGSYNC_SLASH7)
-		DEFAULT_CHAT_FRAME:AddMessage(BAGSYNC_SLASH8)
+		for i=1, 9 do
+			DEFAULT_CHAT_FRAME:AddMessage(_G["BAGSYNC_SLASH"..i])
+		end
 	end

-	DEFAULT_CHAT_FRAME:AddMessage("|cFF99CC33BagSync|r [v|cFFDF2B2B"..ver.."|r] loaded: /bgs, /bagsync")
+	DEFAULT_CHAT_FRAME:AddMessage("|cFF99CC33BagSync|r [v|cFFDF2B2B"..ver.."|r] loaded:   /bgs, /bagsync")

 	--we deleted someone with the Profile Window, display name of user deleted
 	if BagSyncOpt.delName then
@@ -276,6 +280,7 @@ function BagSync:StartupDB()
 	BagSyncOpt = BagSyncOpt or {}
 	if BagSyncOpt.showTotal == nil then BagSyncOpt.showTotal = true end
 	if BagSyncOpt.showGuildNames == nil then BagSyncOpt.showGuildNames = false end
+	if BagSyncOpt.enableThrottle == nil then BagSyncOpt.enableThrottle = true end

 	BagSyncGUILD_DB = BagSyncGUILD_DB or {}
 	BagSyncGUILD_DB[currentRealm] = BagSyncGUILD_DB[currentRealm] or {}
@@ -981,11 +986,12 @@ local function AddOwners(frame, link)

 	--loop through our characters
 	for k, v in pairs(BagSyncDB[currentRealm]) do
+
 		local infoString
 		local invCount, bankCount, equipCount, guildCount, mailboxCount = 0, 0, 0, 0, 0

 		--now count the stuff for the user
-		for q, r in pairs(BagSyncDB[currentRealm][k]) do
+		for q, r in pairs(v) do
 			if itemLink then
 				local dblink, dbcount = strsplit(',', r)
 				if dblink then
@@ -1004,7 +1010,7 @@ local function AddOwners(frame, link)
 			end
 		end

-		local guildN = BagSyncDB[currentRealm][k].guild or nil
+		local guildN = v.guild or nil

 		--check the guild bank if the character is in a guild
 		if BS_GD and guildN and BS_GD[guildN] then
@@ -1060,7 +1066,24 @@ local function HookTip(tooltip)
 	tooltip:HookScript('OnTooltipSetItem', function(self, ...)
 		local itemLink = select(2, self:GetItem())
 		if itemLink and GetItemInfo(itemLink) then
-			AddOwners(self, itemLink)
+			local itemName = GetItemInfo(itemLink)
+			if BagSyncOpt.enableThrottle then
+				if not self.BagSyncThrottle then self.BagSyncThrottle = GetTime() end
+				if not self.BagSyncPrevious then self.BagSyncPrevious = itemName end
+
+				if itemName ~= self.BagSyncPrevious then
+					self.BagSyncPrevious = itemName
+					self.BagSyncThrottle = GetTime()
+				end
+				if self:GetName() == "GameTooltip" and (GetTime() - self.BagSyncThrottle) >= 0.05 then
+					AddOwners(self, itemLink)
+					self.BagSyncThrottle = GetTime()
+				elseif self:GetName() ~= "GameTooltip" then
+					AddOwners(self, itemLink)
+				end
+			else
+				AddOwners(self, itemLink)
+			end
 		end
 	end)
 end
diff --git a/BagSync.toc b/BagSync.toc
index 6562fa7..65251b3 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: 3.7
+## Version: 3.8
 ## SavedVariables: BagSyncDB, BagSyncOpt, BagSyncGUILD_DB, BagSyncTOKEN_DB

 localization\localization.lua
diff --git a/localization/localization.lua b/localization/localization.lua
index 8140ecb..b6ea8e8 100644
--- a/localization/localization.lua
+++ b/localization/localization.lua
@@ -30,6 +30,7 @@ if ( GetLocale() == "zhCN" ) then
 	BAGSYNC_SLASH_CMD6 = 'fixdb'
 	BAGSYNC_SLASH_CMD7 = 'total'
 	BAGSYNC_SLASH_CMD8 = 'guildname'
+	BAGSYNC_SLASH_CMD9 = 'throttle'
 	BAGSYNC_SLASH1 = '/bgs '..BAGSYNC_SLASH_CMD1..' - Does a quick search for an item'
 	BAGSYNC_SLASH2 = '/bgs '..BAGSYNC_SLASH_CMD2..' - Opens the search window'
 	BAGSYNC_SLASH3 = '/bgs '..BAGSYNC_SLASH_CMD3..' - Displays a tooltip with the amount of gold on each character.'
@@ -38,6 +39,7 @@ if ( GetLocale() == "zhCN" ) then
 	BAGSYNC_SLASH6 = '/bgs '..BAGSYNC_SLASH_CMD6..' - Runs the database fix (FixDB) on BagSync.'
 	BAGSYNC_SLASH7 = '/bgs '..BAGSYNC_SLASH_CMD7..' - Toggles the [Total] display in tooltips and gold display.'
 	BAGSYNC_SLASH8 = '/bgs '..BAGSYNC_SLASH_CMD8..' - Toggles the [Guild Name] display in tooltips.'
+	BAGSYNC_SLASH9 = '/bgs '..BAGSYNC_SLASH_CMD9..' - Toggles the throttle when displaying tooltips. (ON = Prevents Lag).'

 elseif ( GetLocale() == "ruRU" )  then
 	--thanks to senryo from WOWInterface
@@ -68,6 +70,7 @@ elseif ( GetLocale() == "ruRU" )  then
 	BAGSYNC_SLASH_CMD6 = 'fixdb'
 	BAGSYNC_SLASH_CMD7 = 'total'
 	BAGSYNC_SLASH_CMD8 = 'guildname'
+	BAGSYNC_SLASH_CMD9 = 'throttle'
 	BAGSYNC_SLASH1 = '/bgs '..BAGSYNC_SLASH_CMD1..' - Does a quick search for an item'
 	BAGSYNC_SLASH2 = '/bgs '..BAGSYNC_SLASH_CMD2..' - Opens the search window'
 	BAGSYNC_SLASH3 = '/bgs '..BAGSYNC_SLASH_CMD3..' - Displays a tooltip with the amount of gold on each character.'
@@ -76,6 +79,7 @@ elseif ( GetLocale() == "ruRU" )  then
 	BAGSYNC_SLASH6 = '/bgs '..BAGSYNC_SLASH_CMD6..' - Runs the database fix (FixDB) on BagSync.'
 	BAGSYNC_SLASH7 = '/bgs '..BAGSYNC_SLASH_CMD7..' - Toggles the [Total] display in tooltips and gold display.'
 	BAGSYNC_SLASH8 = '/bgs '..BAGSYNC_SLASH_CMD8..' - Toggles the [Guild Name] display in tooltips.'
+	BAGSYNC_SLASH9 = '/bgs '..BAGSYNC_SLASH_CMD9..' - Toggles the throttle when displaying tooltips. (ON = Prevents Lag).'

 elseif ( GetLocale() == "zhTW" ) then

@@ -105,6 +109,7 @@ elseif ( GetLocale() == "zhTW" ) then
 	BAGSYNC_SLASH_CMD6 = 'fixdb'
 	BAGSYNC_SLASH_CMD7 = 'total'
 	BAGSYNC_SLASH_CMD8 = 'guildname'
+	BAGSYNC_SLASH_CMD9 = 'throttle'
 	BAGSYNC_SLASH1 = '/bgs '..BAGSYNC_SLASH_CMD1..' - Does a quick search for an item'
 	BAGSYNC_SLASH2 = '/bgs '..BAGSYNC_SLASH_CMD2..' - Opens the search window'
 	BAGSYNC_SLASH3 = '/bgs '..BAGSYNC_SLASH_CMD3..' - Displays a tooltip with the amount of gold on each character.'
@@ -113,6 +118,7 @@ elseif ( GetLocale() == "zhTW" ) then
 	BAGSYNC_SLASH6 = '/bgs '..BAGSYNC_SLASH_CMD6..' - Runs the database fix (FixDB) on BagSync.'
 	BAGSYNC_SLASH7 = '/bgs '..BAGSYNC_SLASH_CMD7..' - Toggles the [Total] display in tooltips and gold display.'
 	BAGSYNC_SLASH8 = '/bgs '..BAGSYNC_SLASH_CMD8..' - Toggles the [Guild Name] display in tooltips.'
+	BAGSYNC_SLASH9 = '/bgs '..BAGSYNC_SLASH_CMD9..' - Toggles the throttle when displaying tooltips. (ON = Prevents Lag).'

 elseif ( GetLocale() == "frFR" ) then
 	--thanks to cacahuete from WOWInterface
@@ -143,6 +149,7 @@ elseif ( GetLocale() == "frFR" ) then
 	BAGSYNC_SLASH_CMD6 = 'fixdb'
 	BAGSYNC_SLASH_CMD7 = 'total'
 	BAGSYNC_SLASH_CMD8 = 'guildname'
+	BAGSYNC_SLASH_CMD9 = 'throttle'
 	BAGSYNC_SLASH1 = '/bgs '..BAGSYNC_SLASH_CMD1..' - Does a quick search for an item'
 	BAGSYNC_SLASH2 = '/bgs '..BAGSYNC_SLASH_CMD2..' - Opens the search window'
 	BAGSYNC_SLASH3 = '/bgs '..BAGSYNC_SLASH_CMD3..' - Displays a tooltip with the amount of gold on each character.'
@@ -151,6 +158,7 @@ elseif ( GetLocale() == "frFR" ) then
 	BAGSYNC_SLASH6 = '/bgs '..BAGSYNC_SLASH_CMD6..' - Runs the database fix (FixDB) on BagSync.'
 	BAGSYNC_SLASH7 = '/bgs '..BAGSYNC_SLASH_CMD7..' - Toggles the [Total] display in tooltips and gold display.'
 	BAGSYNC_SLASH8 = '/bgs '..BAGSYNC_SLASH_CMD8..' - Toggles the [Guild Name] display in tooltips.'
+	BAGSYNC_SLASH9 = '/bgs '..BAGSYNC_SLASH_CMD9..' - Toggles the throttle when displaying tooltips. (ON = Prevents Lag).'

 elseif ( GetLocale() == "koKR" ) then
 	--thanks to zinzzalimp from WOWInterface
@@ -181,6 +189,7 @@ elseif ( GetLocale() == "koKR" ) then
 	BAGSYNC_SLASH_CMD6 = 'fixdb'
 	BAGSYNC_SLASH_CMD7 = 'total'
 	BAGSYNC_SLASH_CMD8 = 'guildname'
+	BAGSYNC_SLASH_CMD9 = 'throttle'
 	BAGSYNC_SLASH1 = '/bgs '..BAGSYNC_SLASH_CMD1..' - 빠른 아이템 찾기'
 	BAGSYNC_SLASH2 = '/bgs '..BAGSYNC_SLASH_CMD2..' - 검색창 열기'
 	BAGSYNC_SLASH3 = '/bgs '..BAGSYNC_SLASH_CMD3..' - 툴팁에 각 케릭터의 골드량을 표시합니다.'
@@ -189,6 +198,7 @@ elseif ( GetLocale() == "koKR" ) then
 	BAGSYNC_SLASH6 = '/bgs '..BAGSYNC_SLASH_CMD6..' - Runs the database fix (FixDB) on BagSync.'
 	BAGSYNC_SLASH7 = '/bgs '..BAGSYNC_SLASH_CMD7..' - Toggles the [Total] display in tooltips and gold display.'
 	BAGSYNC_SLASH8 = '/bgs '..BAGSYNC_SLASH_CMD8..' - Toggles the [Guild Name] display in tooltips.'
+	BAGSYNC_SLASH9 = '/bgs '..BAGSYNC_SLASH_CMD9..' - Toggles the throttle when displaying tooltips. (ON = Prevents Lag).'

 elseif ( GetLocale() == "deDE" ) then
 	--thanks to Schnubby from WOWInterface
@@ -219,6 +229,7 @@ elseif ( GetLocale() == "deDE" ) then
 	BAGSYNC_SLASH_CMD6 = 'fixdb'
 	BAGSYNC_SLASH_CMD7 = 'total'
 	BAGSYNC_SLASH_CMD8 = 'guildname'
+	BAGSYNC_SLASH_CMD9 = 'throttle'
 	BAGSYNC_SLASH1 = '/bgs '..BAGSYNC_SLASH_CMD1..' - Nach einem Item suchen'
 	BAGSYNC_SLASH2 = '/bgs '..BAGSYNC_SLASH_CMD2..' - Öffnet das Suchfenster'
 	BAGSYNC_SLASH3 = '/bgs '..BAGSYNC_SLASH_CMD3..' - Zeigt einen Tooltip mit dem Gold eines jeden Charakters.'
@@ -227,6 +238,7 @@ elseif ( GetLocale() == "deDE" ) then
 	BAGSYNC_SLASH6 = '/bgs '..BAGSYNC_SLASH_CMD6..' - Führt eine Reparatur der Datenbank (FixDB) aus.'
 	BAGSYNC_SLASH7 = '/bgs '..BAGSYNC_SLASH_CMD7..' - Zeigt/Verbirgt die [Gesamt] Anzeige in Tooltips für Items und in der Goldanzeige.'
 	BAGSYNC_SLASH8 = '/bgs '..BAGSYNC_SLASH_CMD8..' - Toggles the [Guild Name] display in tooltips.'
+	BAGSYNC_SLASH9 = '/bgs '..BAGSYNC_SLASH_CMD9..' - Toggles the throttle when displaying tooltips. (ON = Prevents Lag).'

 else

@@ -256,6 +268,7 @@ else
 	BAGSYNC_SLASH_CMD6 = 'fixdb'
 	BAGSYNC_SLASH_CMD7 = 'total'
 	BAGSYNC_SLASH_CMD8 = 'guildname'
+	BAGSYNC_SLASH_CMD9 = 'throttle'
 	BAGSYNC_SLASH1 = '/bgs '..BAGSYNC_SLASH_CMD1..' - Does a quick search for an item'
 	BAGSYNC_SLASH2 = '/bgs '..BAGSYNC_SLASH_CMD2..' - Opens the search window'
 	BAGSYNC_SLASH3 = '/bgs '..BAGSYNC_SLASH_CMD3..' - Displays a tooltip with the amount of gold on each character.'
@@ -264,6 +277,7 @@ else
 	BAGSYNC_SLASH6 = '/bgs '..BAGSYNC_SLASH_CMD6..' - Runs the database fix (FixDB) on BagSync.'
 	BAGSYNC_SLASH7 = '/bgs '..BAGSYNC_SLASH_CMD7..' - Toggles the [Total] display in tooltips and gold display.'
 	BAGSYNC_SLASH8 = '/bgs '..BAGSYNC_SLASH_CMD8..' - Toggles the [Guild Name] display in tooltips.'
+	BAGSYNC_SLASH9 = '/bgs '..BAGSYNC_SLASH_CMD9..' - Toggles the throttle when displaying tooltips. (ON = Prevents Lag).'

 end