Quantcast

Now with support for Heirlooms

kibsgaard [08-20-14 - 08:18]
Now with support for Heirlooms

Signed-off-by: kibsgaard <kibsgaard@curseforge.com>
Filename
KibsItemLevel.lua
diff --git a/KibsItemLevel.lua b/KibsItemLevel.lua
index dfb1736..aaaefc5 100644
--- a/KibsItemLevel.lua
+++ b/KibsItemLevel.lua
@@ -34,10 +34,11 @@ local KibsItemLevelConfig_defaultColor = true;



-local emptySockets = { ["Meta "]    = "INTERFACE/ITEMSOCKETINGFRAME/UI-EmptySocket-Prismatic",
+local emptySockets = { ["Meta "]    = "INTERFACE/ITEMSOCKETINGFRAME/UI-EmptySocket-Meta",
                       ["Red "]     = "INTERFACE/ITEMSOCKETINGFRAME/UI-EmptySocket-Red",
                       ["Blue "]    = "INTERFACE/ITEMSOCKETINGFRAME/UI-EmptySocket-Blue",
 					  ["Yellow "]  = "INTERFACE/ITEMSOCKETINGFRAME/UI-EmptySocket-Yellow",
+					  ["Prismatic "]  = "INTERFACE/ITEMSOCKETINGFRAME/UI-EmptySocket-Prismatic",
                     } ;

 local enchatableItems={ [ 1  ] = nil,
@@ -125,10 +126,13 @@ function setupEventHandler(self,event,...)
 		KibsItemLevelFrame_VARIABLES_LOADED();
 		ilvlFrame:RegisterEvent("PLAYER_EQUIPMENT_CHANGED");
 		ilvlFrame:RegisterEvent("SOCKET_INFO_CLOSE");
+		ilvlFrame:RegisterEvent("SOCKET_INFO_SUCCESS");
+		ilvlFrame:RegisterEvent("SOCKET_INFO_UPDATE");
 		ilvlFrame:RegisterEvent("PLAYER_ENTERING_WORLD");
 		ilvlFrame:RegisterEvent("INSPECT_READY");
 		ilvlFrame:SetScript("OnEvent",eventHandler);
-		KIL_wait(3,findItemInfo,"player");
+		--KIL_wait(0.2,findItemInfo,"player");
+		findItemInfo("player");
 	end
 end
 ilvlFrame:SetScript("OnEvent",setupEventHandler);
@@ -243,31 +247,42 @@ function findItemInfo(who)
 				local upgrade, max, delta = ItemUpgradeInfo:GetItemUpgradeInfo(itemlink)
 				local ilvl = ItemUpgradeInfo:GetUpgradedItemLevel(itemlink)
 				if not(ilvl) then ilvl = 0; end
-				if (upgrade and KibsItemLevelConfig.upgrades) then
-					ActiveFontStrings[i]:SetText(ilvl .." ("..upgrade.."/"..max..")")
-				else
-					ActiveFontStrings[i]:SetText(ilvl)
-
-				end
+
 				findSockets(who,i,slotID);
-				if(ilvl)then
-					tilvl = tilvl + ilvl;
-				end
+
 				numItems = numItems + 1;
 				local line = "";
 				GameTooltip:SetOwner(ilvlFrame,"CENTER");
 				GameTooltip:SetHyperlink(itemlink);
-					for i = 2, GameTooltip:NumLines() do
+				for i = 2, GameTooltip:NumLines() do
 					line = _G[GameTooltip:GetName().."TextLeft"..i];
 					if (line) then
 						line = line:GetText();
 						if (line) then
 							if (line:find(ENCHANTED)) then
 								enchantInfo = line;
+							elseif(ilvl == 1) then
+								if(line:match("Requires level")) then
+									local n = line:sub(line:find("%(") + 1,line:find("%)") - 1);
+									if n then
+										ilvl = n ;
+									end
+								end
 							end
 						end
 					end
 				end
+
+				if (upgrade and KibsItemLevelConfig.upgrades) then
+					ActiveFontStrings[i]:SetText(ilvl .." ("..upgrade.."/"..max..")")
+				else
+					ActiveFontStrings[i]:SetText(ilvl)
+				end
+
+				if(ilvl)then
+					tilvl = tilvl + ilvl;
+				end
+
 				if(enchantInfo) then
 					ActiveEnchantIcons[i].texture:SetTexture("INTERFACE/ICONS/INV_Jewelry_Talisman_08");
 					ActiveEnchantIcons[i].texture:SetAlpha(1.0);
@@ -329,6 +344,12 @@ function findSockets(who,slot,slotID)
 								sockets = sockets + 1;
 							end
 						end
+						--else if(line:find("Touched\"")) then --UNCOMMENT TO SUPPORT SHA-TOUCHED SOCKETS
+							--ActiveIcons[sockets].texture:SetTexture("INTERFACE/ITEMSOCKETINGFRAME/UI-EMPTYSOCKET-HYDRAULIC");
+							--ActiveIcons[sockets].texture:SetAlpha(1.0);
+							--sockets = sockets + 1;
+						--end
+
 					end
 				end
 			end