helpers: move GetItemLinkByName and add caching
This commit is contained in:
+17
@@ -346,3 +346,20 @@ ShaguTweaks.GetItemCount = function(itemName)
|
|||||||
|
|
||||||
return count
|
return count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local itemLinkByNameCache = {}
|
||||||
|
ShaguTweaks.GetItemLinkByName = function(name)
|
||||||
|
if itemLinkByNameCache[name] then
|
||||||
|
return itemLinkByNameCache[name]
|
||||||
|
end
|
||||||
|
|
||||||
|
for itemID = 1, 25818 do
|
||||||
|
local itemName, itemLink, itemQuality = GetItemInfo(itemID)
|
||||||
|
if (itemName and itemName == name) then
|
||||||
|
local _, _, _, hex = GetItemQualityColor(tonumber(itemQuality))
|
||||||
|
local hyperLink = hex.. "|H".. itemLink .."|h["..itemName.."]|h" .. FONT_COLOR_CODE_CLOSE
|
||||||
|
itemLinkByNameCache[name] = hyperLink
|
||||||
|
return hyperLink
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
+1
-10
@@ -1,6 +1,7 @@
|
|||||||
local _G = ShaguTweaks.GetGlobalEnv()
|
local _G = ShaguTweaks.GetGlobalEnv()
|
||||||
local T = ShaguTweaks.T
|
local T = ShaguTweaks.T
|
||||||
local GetExpansion = ShaguTweaks.GetExpansion
|
local GetExpansion = ShaguTweaks.GetExpansion
|
||||||
|
local GetItemLinkByName = ShaguTweaks.GetItemLinkByName
|
||||||
|
|
||||||
local module = ShaguTweaks:register({
|
local module = ShaguTweaks:register({
|
||||||
title = T["Vendor Values"],
|
title = T["Vendor Values"],
|
||||||
@@ -3868,16 +3869,6 @@ end
|
|||||||
|
|
||||||
ShaguTweaks.SellValueDB = data
|
ShaguTweaks.SellValueDB = data
|
||||||
|
|
||||||
local function GetItemLinkByName(name)
|
|
||||||
for itemID = 1, 25818 do
|
|
||||||
local itemName, hyperLink, itemQuality = GetItemInfo(itemID)
|
|
||||||
if (itemName and itemName == name) then
|
|
||||||
local _, _, _, hex = GetItemQualityColor(tonumber(itemQuality))
|
|
||||||
return hex.. "|H"..hyperLink.."|h["..itemName.."]|h|r"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function AddVendorPrices(frame, id, count)
|
local function AddVendorPrices(frame, id, count)
|
||||||
if ShaguTweaks.SellValueDB[id] and ShaguTweaks.SellValueDB[id] > 0 then
|
if ShaguTweaks.SellValueDB[id] and ShaguTweaks.SellValueDB[id] > 0 then
|
||||||
SetTooltipMoney(frame, ShaguTweaks.SellValueDB[id] * count)
|
SetTooltipMoney(frame, ShaguTweaks.SellValueDB[id] * count)
|
||||||
|
|||||||
Reference in New Issue
Block a user