fix: itemRack equipment sets
This commit is contained in:
+98
-29
@@ -144,41 +144,95 @@ end
|
|||||||
-- ItemRack Integration
|
-- ItemRack Integration
|
||||||
-------------------------------------------
|
-------------------------------------------
|
||||||
|
|
||||||
local function ScanItemRack()
|
local function ExtractItemRackID(value)
|
||||||
-- Check if ItemRack is loaded
|
-- Accepts a number, a bare-id string "12345", or an item link fragment
|
||||||
if not ItemRackUser or not ItemRackUser.Sets then return false end
|
-- like "item:12345:0:0:0". Returns numeric itemID or nil.
|
||||||
|
if type(value) == "number" then
|
||||||
|
return value > 0 and value or nil
|
||||||
|
end
|
||||||
|
if type(value) ~= "string" then return nil end
|
||||||
|
local _, _, idStr = string.find(value, "item:(%d+)")
|
||||||
|
if not idStr then
|
||||||
|
_, _, idStr = string.find(value, "^(%d+)")
|
||||||
|
end
|
||||||
|
local itemID = tonumber(idStr)
|
||||||
|
if itemID and itemID > 0 then return itemID end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
addon:Debug("EquipmentSets: Scanning ItemRack sets...")
|
local function ScanItemRackStock(sets)
|
||||||
|
-- Stock Gello ItemRack: ItemRackUser.Sets[name].equip[slot] = "itemID:..."
|
||||||
local scannedSets = 0
|
-- Internal sets start with "~".
|
||||||
for setName, setInfo in pairs(ItemRackUser.Sets) do
|
local scanned = 0
|
||||||
-- Skip internal sets (start with special chars)
|
for setName, setInfo in pairs(sets) do
|
||||||
if not string.find(setName, "^~") then
|
if type(setName) == "string" and not string.find(setName, "^~") then
|
||||||
local itemIDs = {}
|
local itemIDs = {}
|
||||||
if setInfo.equip then
|
if type(setInfo) == "table" and setInfo.equip then
|
||||||
for slot, itemString in pairs(setInfo.equip) do
|
for _, itemString in pairs(setInfo.equip) do
|
||||||
-- ItemRack format: "itemID:enchant:suffix:unique"
|
local itemID = ExtractItemRackID(itemString)
|
||||||
if type(itemString) == "string" then
|
if itemID then itemIDs[itemID] = true end
|
||||||
local _, _, idStr = string.find(itemString, "^(%d+)")
|
|
||||||
local itemID = tonumber(idStr)
|
|
||||||
if itemID and itemID > 0 then
|
|
||||||
itemIDs[itemID] = true
|
|
||||||
end
|
|
||||||
elseif type(itemString) == "number" then
|
|
||||||
if itemString > 0 then
|
|
||||||
itemIDs[itemString] = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
setData[setName] = { itemIDs = itemIDs, source = "ItemRack" }
|
setData[setName] = { itemIDs = itemIDs, source = "ItemRack" }
|
||||||
scannedSets = scannedSets + 1
|
scanned = scanned + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return scanned
|
||||||
|
end
|
||||||
|
|
||||||
|
local function ScanItemRackFork(sets)
|
||||||
|
-- Turtle/Khalil ItemRack fork: Rack_User[user].Sets[name][slotNum] =
|
||||||
|
-- { id = "item:<id>:<enchant>:<suffix>", name = "ItemName" }. Internal
|
||||||
|
-- sets are prefixed "Rack-" or "ItemRack".
|
||||||
|
local scanned = 0
|
||||||
|
for setName, setInfo in pairs(sets) do
|
||||||
|
if type(setName) == "string"
|
||||||
|
and not string.find(setName, "^Rack%-")
|
||||||
|
and not string.find(setName, "^ItemRack")
|
||||||
|
and type(setInfo) == "table" then
|
||||||
|
local itemIDs = {}
|
||||||
|
for k, v in pairs(setInfo) do
|
||||||
|
if type(k) == "number" and type(v) == "table" then
|
||||||
|
local itemID = ExtractItemRackID(v.id)
|
||||||
|
if itemID then itemIDs[itemID] = true end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
setData[setName] = { itemIDs = itemIDs, source = "ItemRack" }
|
||||||
|
scanned = scanned + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return scanned
|
||||||
|
end
|
||||||
|
|
||||||
|
local function IsItemRackLoaded()
|
||||||
|
if ItemRackUser and ItemRackUser.Sets then return true end
|
||||||
|
if Rack_User then
|
||||||
|
local userKey = UnitName("player") .. " of " .. GetRealmName()
|
||||||
|
if Rack_User[userKey] and Rack_User[userKey].Sets then return true end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local function ScanItemRack()
|
||||||
|
local scannedSets = 0
|
||||||
|
|
||||||
|
if ItemRackUser and ItemRackUser.Sets then
|
||||||
|
addon:Debug("EquipmentSets: Scanning ItemRack (stock) sets...")
|
||||||
|
scannedSets = scannedSets + ScanItemRackStock(ItemRackUser.Sets)
|
||||||
|
end
|
||||||
|
|
||||||
|
if Rack_User then
|
||||||
|
local userKey = UnitName("player") .. " of " .. GetRealmName()
|
||||||
|
local userData = Rack_User[userKey]
|
||||||
|
if userData and userData.Sets then
|
||||||
|
addon:Debug("EquipmentSets: Scanning ItemRack (fork) sets for " .. userKey)
|
||||||
|
scannedSets = scannedSets + ScanItemRackFork(userData.Sets)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if scannedSets == 0 then return false end
|
||||||
addon:Debug("EquipmentSets: Scanned %d ItemRack sets", scannedSets)
|
addon:Debug("EquipmentSets: Scanned %d ItemRack sets", scannedSets)
|
||||||
return scannedSets > 0
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
-------------------------------------------
|
-------------------------------------------
|
||||||
@@ -233,8 +287,8 @@ function EquipmentSets:Initialize()
|
|||||||
FullScan()
|
FullScan()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check if ItemRack is already loaded
|
-- Check if ItemRack is already loaded (stock or fork)
|
||||||
if ItemRackUser and ItemRackUser.Sets then
|
if IsItemRackLoaded() then
|
||||||
itemRackReady = true
|
itemRackReady = true
|
||||||
FullScan()
|
FullScan()
|
||||||
end
|
end
|
||||||
@@ -264,13 +318,28 @@ function EquipmentSets:Initialize()
|
|||||||
if this.checks > 30 then
|
if this.checks > 30 then
|
||||||
this:Hide()
|
this:Hide()
|
||||||
-- Do a final scan anyway in case addons loaded without events
|
-- Do a final scan anyway in case addons loaded without events
|
||||||
if Outfitter_GetCategoryOrder or (ItemRackUser and ItemRackUser.Sets) then
|
if Outfitter_GetCategoryOrder or IsItemRackLoaded() then
|
||||||
FullScan()
|
FullScan()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
initCheckFrame:Show()
|
initCheckFrame:Show()
|
||||||
|
|
||||||
|
-- Initial scan: PLAYER_LOGIN runs after PLAYER_ENTERING_WORLD and any
|
||||||
|
-- ADDON_LOADED for addons that loaded before Guda, so the handlers
|
||||||
|
-- registered above would miss the initial session for already-loaded
|
||||||
|
-- ItemRack/Outfitter. Catch them here.
|
||||||
|
if Outfitter_GetCategoryOrder or gOutfitter_Initialized then
|
||||||
|
outfitterReady = true
|
||||||
|
HookOutfitterEvents()
|
||||||
|
end
|
||||||
|
if IsItemRackLoaded() then
|
||||||
|
itemRackReady = true
|
||||||
|
end
|
||||||
|
if outfitterReady or itemRackReady then
|
||||||
|
FullScan()
|
||||||
|
end
|
||||||
|
|
||||||
addon:Debug("EquipmentSets: Module initialized")
|
addon:Debug("EquipmentSets: Module initialized")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user