Quantcast

Fixed lag-issues when changing a lot of gear at once.

kibsgaard [08-17-14 - 21:50]
Fixed lag-issues when changing a lot of gear at once.
Inspection now updates even more times and now over 6 seconds (as the INSPECT_READY event is fired way too early)
Fixed a nil-error while reading enchants (thanks bljakk)

To-do
- Localization
- Colors on ilvl depending on rarity of the items

Signed-off-by: kibsgaard <kibsgaard@curseforge.com>
Filename
KibsItemLevel.lua
diff --git a/KibsItemLevel.lua b/KibsItemLevel.lua
index 4b7c019..9ccf694 100644
--- a/KibsItemLevel.lua
+++ b/KibsItemLevel.lua
@@ -15,6 +15,8 @@ local ilvlFrame = CreateFrame("frame");
 local iconSize = 16;
 local iconOffset = 18;
 local fontStyle = "SystemFont_Med1";
+local UpdateInProgress = false;
+local UpdateInProgressInspect = false;
 ilvlFrame:RegisterEvent("VARIABLES_LOADED");

 -- Globals
@@ -28,6 +30,7 @@ local KibsItemLevelConfig_defaultOn = true;
 local KibsItemLevelConfig_defaultUpgrades = false;
 local KibsItemLevelConfig_defaultCharacter = true;
 local KibsItemLevelConfig_defaultInspection = true;
+local KibsItemLevelConfig_defaultColor = true;



@@ -94,13 +97,23 @@ function eventHandler(self,event,...)
 	if(KibsItemLevelConfig.on)then
 		if (event == "INSPECT_READY" and KibsItemLevelConfig.Inspection) then
 			if(InspectFrame.unit)then
-				findItemInfo(InspectFrame.unit);
-				KIL_wait(1.5,findItemInfo,InspectFrame.unit);
-				KIL_wait(3,findItemInfo,InspectFrame.unit);
+				if(UpdateInProgressInspect == false) then
+					findItemInfo(InspectFrame.unit);
+					KIL_wait(1.5,findItemInfo,InspectFrame.unit);
+					KIL_wait(3,findItemInfo,InspectFrame.unit);
+					KIL_wait(5,findItemInfo,InspectFrame.unit);
+					UpdateInProgressInspect = true;
+				end
 			end
 		elseif(KibsItemLevelConfig.Character) then
-			findItemInfo("player");
-			KIL_wait(5,findItemInfo,"player");
+
+			if(UpdateInProgress == false) then
+			UpdateInProgress = true;
+			--findItemInfo("player");
+			KIL_wait(0.2,findItemInfo,"player");
+			KIL_wait(3,findItemInfo,"player");
+
+			end
 		end
 	end
 end
@@ -205,10 +218,12 @@ function findItemInfo(who)
 		ActiveFontStrings = FontStrings;
 		ActiveIcons = Icons;
 		ActiveEnchantIcons = EnchantIcons;
+		UpdateInProgress = false;
 	else
 		ActiveFontStrings = InspectFontStrings;
 		ActiveIcons = InspectIcons;
 		ActiveEnchantIcons = InspectEnchantIcons;
+		UpdateInProgressInspect = false;
 	end

 	GameTooltip:Hide();
@@ -232,6 +247,7 @@ function findItemInfo(who)
 					ActiveFontStrings[i]:SetText(ilvl .." ("..upgrade.."/"..max..")")
 				else
 					ActiveFontStrings[i]:SetText(ilvl)
+
 				end
 				findSockets(who,i,slotID);
 				if(ilvl)then
@@ -245,8 +261,10 @@ function findItemInfo(who)
 					line = _G[GameTooltip:GetName().."TextLeft"..i];
 					if (line) then
 						line = line:GetText();
-						if (line:find("Enchanted:")) then
-							enchantInfo = line;
+						if (line) then
+							if (line:find("Enchanted:")) then
+								enchantInfo = line;
+							end
 						end
 					end
 				end