Browse Source

Will query the server for any uncached recipe items during login (#12)

pull/13/head 2.13
Xan-Asc 2 years ago committed by GitHub
parent
commit
a23e8cdb4f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 11
      TradeSkillMaster/Core/Options.lua
  2. 22
      TradeSkillMaster/TradeSkillMaster.lua
  3. 5
      TradeSkillMaster_Crafting/Modules/CraftingGUI.lua

11
TradeSkillMaster/Core/Options.lua

@ -939,6 +939,17 @@ function private:LoadProfilesPage(container)
end end
end end
local bulkquerybuffer = {}
for itemString, _ in pairs(TSM.db.profile.items) do
-- check if item is cached
local _,_,itemID = itemString:find("item:(%d+)")
if itemID then
local item = Item:CreateFromID(itemID)
if not item:IsCached() then bulkquerybuffer[#bulkquerybuffer+1] = item.itemID end
end
end
TSMAPI:BulkQuery(bulkquerybuffer)
return profiles return profiles
end end

22
TradeSkillMaster/TradeSkillMaster.lua

@ -1,4 +1,4 @@
-- ------------------------------------------------------------------------------ -- -- ------------------------------------------------------------------------------ --
-- TradeSkillMaster -- -- TradeSkillMaster --
-- http://www.curse.com/addons/wow/tradeskill-master -- -- http://www.curse.com/addons/wow/tradeskill-master --
-- -- -- --
@ -234,15 +234,22 @@ function TSM:OnInitialize()
-- create the main TSM frame -- create the main TSM frame
TSM:CreateMainFrame() TSM:CreateMainFrame()
local bulkquerybuffer = {}
-- fix any items with spaces in them -- fix any items with spaces in them
for itemString, groupPath in pairs(TSM.db.profile.items) do for itemString, groupPath in pairs(TSM.db.profile.items) do
-- check if item is cached
local _,_,itemID = itemString:find("item:(%d+)")
if itemID then
local item = Item:CreateFromID(itemID)
if not item:IsCached() then bulkquerybuffer[#bulkquerybuffer+1] = item.itemID end
end
if strfind(itemString, " ") then if strfind(itemString, " ") then
local newItemString = gsub(itemString, " ", "") local newItemString = gsub(itemString, " ", "")
TSM.db.profile.items[newItemString] = groupPath TSM.db.profile.items[newItemString] = groupPath
TSM.db.profile.items[itemString] = nil TSM.db.profile.items[itemString] = nil
end end
end end
TSMAPI:BulkQuery(bulkquerybuffer)
if TSM.db.profile.deValueSource then if TSM.db.profile.deValueSource then
TSM.db.profile.destroyValueSource = TSM.db.profile.deValueSource TSM.db.profile.destroyValueSource = TSM.db.profile.deValueSource
@ -706,3 +713,14 @@ function TSM:GetAuctionPlayer(player, player_full)
return player return player
end end
end end
-- Bulk load uncached IDs. Divides in to buckets of 50
function TSMAPI:BulkQuery(items)
self.QueryTicker = Timer.NewTicker(1, function()
Item:BulkContinueOnLoad(table.take(items, 50), function(id) end, function(id) return GetItemInfo(id) == nil end) -- 3rd parameter (validator) is optional
if #items == 0 then
self.QueryTicker:Cancel()
self.QueryTicker = nil
end
end)
end

5
TradeSkillMaster_Crafting/Modules/CraftingGUI.lua

@ -282,7 +282,7 @@ function GUI:UpdateTradeSkills(...)
inSecondary = false inSecondary = false
elseif inProfessions == true or inSecondary == true then elseif inProfessions == true or inSecondary == true then
if skillName ~= nil and (not filterTrade or filterTrade == skillName) and not invalidTrade[skillName] then if skillName ~= nil and (not filterTrade or filterTrade == skillName) and not invalidTrade[skillName] then
if skillName == "Mining" then skillName = "Smelting" end -- bandaid for mining as related spell is different than craft -- if skillName == "Mining" then skillName = "Smelting" end -- bandaid for mining as related spell is different than craft
TSM.db.realm.tradeSkills[playerName][skillName] = old[skillName] or {} TSM.db.realm.tradeSkills[playerName][skillName] = old[skillName] or {}
TSM.db.realm.tradeSkills[playerName][skillName].level = skillRank TSM.db.realm.tradeSkills[playerName][skillName].level = skillRank
TSM.db.realm.tradeSkills[playerName][skillName].maxLevel = skillMaxRank TSM.db.realm.tradeSkills[playerName][skillName].maxLevel = skillMaxRank
@ -2568,6 +2568,9 @@ function GUI:UpdateGathering()
end end
availableMats[itemString] = availQty availableMats[itemString] = availQty
local name = select(1, TSMAPI:GetSafeItemInfo(itemString)) local name = select(1, TSMAPI:GetSafeItemInfo(itemString))
if not name then
name = GetItemInfo(itemString)
end
local color local color
if need == availQty then if need == availQty then
color = "|cff00ff00" color = "|cff00ff00"

Loading…
Cancel
Save