eqcompare: numeric InventoryType lookup, drop bagtypes/itemtypes locales

Both sub-tables carried per-locale strings only so pfUI's own code could
match against localized text. ClassicAPI's numeric item APIs replace
both:

- GetBagFamily now reads classID/subClassID from C_Item.GetItemInfoInstant
  and switches on the numbers (class 1 = Container, class 11 = Quiver).
- eqcompare pulls the itemID from GameTooltip:GetItem(), fetches the
  numeric invType via C_Item.GetItemInventoryTypeByID, and looks up the
  destination slot(s) in a numeric slotTable keyed by Enum.InventoryType.
  Pair-slot invtypes (finger / trinket / one-hand weapon) list both
  destinations directly, so the "_other" string-concat hack is gone.

Removes the setglobal INVTYPE_* injection, the tooltip text scan, and
the itemtypes + bagtypes locale sub-tables across all 7 files.
This commit is contained in:
Brues
2026-07-01 15:43:03 -05:00
parent 5524ad3b91
commit 439d5a397a
9 changed files with 83 additions and 191 deletions
+12 -12
View File
@@ -28,12 +28,8 @@ function pfUI.api.HasNampower()
return GetNampowerVersion and true or false return GetNampowerVersion and true or false
end end
local isTurtleWoW
function pfUI.api.IsTurtleWoW() function pfUI.api.IsTurtleWoW()
if isTurtleWoW == nil then return C_Spell.GetSpellTexture(46050) == "Interface\\Icons\\Trade_Survival"
isTurtleWoW = C_Spell.GetSpellTexture(46050) == "Interface\\Icons\\Trade_Survival"
end
return isTurtleWoW
end end
-- [ GetUnitDistance ] -- [ GetUnitDistance ]
@@ -434,13 +430,17 @@ function pfUI.api.GetBagFamily(bag)
local id = GetInventoryItemID("player", ContainerIDToInventoryID(bag)) local id = GetInventoryItemID("player", ContainerIDToInventoryID(bag))
if id then if id then
local _, _, _, _, _, itemType, subType = GetItemInfo(id) -- classID 1 = Container (bags), 11 = Quiver
local bagsubtype = L["bagtypes"][subType] -- Container subclasses: 0 = Bag (default), 1 = Soul Bag, 2+ = specialty (herb/enchanting/etc.)
-- Quiver subclasses: 2 = Quiver (arrows), 3 = Ammo Pouch (bullets)
if bagsubtype == "DEFAULT" then return "BAG" end local _, _, _, _, _, classID, subClassID = C_Item.GetItemInfoInstant(id)
if bagsubtype == "SOULBAG" then return "SOULBAG" end if classID == 1 then
if bagsubtype == "QUIVER" then return "QUIVER" end if subClassID == 0 then return "BAG" end
if bagsubtype == nil then return "SPECIAL" end if subClassID == 1 then return "SOULBAG" end
return "SPECIAL"
elseif classID == 11 then
return "QUIVER"
end
end end
return nil return nil
-14
View File
@@ -17,20 +17,6 @@ pfUI_locale["deDE"]["healduration"] = {
["Renew"] = "Erhöht die Wirkungsdauer von 'Erneuerung' um 3 Sek.", ["Renew"] = "Erhöht die Wirkungsdauer von 'Erneuerung' um 3 Sek.",
} }
pfUI_locale["deDE"]["bagtypes"] = {
["Köcher"] = "QUIVER",
["Seelentasche"] = "SOULBAG",
["Behälter"] = "DEFAULT",
}
pfUI_locale["deDE"]["itemtypes"] = {
["INVTYPE_WAND"] = "Zauberstab",
["INVTYPE_THROWN"] = "Wurfwaffe",
["INVTYPE_GUN"] = "Schusswaffe",
["INVTYPE_CROSSBOW"] = "Armbrust",
["INVTYPE_PROJECTILE"] = "Projektil",
}
pfUI_locale["deDE"]["customcast"] = { pfUI_locale["deDE"]["customcast"] = {
["AIMEDSHOT"] = "Gezielter Schuss", ["AIMEDSHOT"] = "Gezielter Schuss",
["MULTISHOT"] = "Mehrfach-Schuss", ["MULTISHOT"] = "Mehrfach-Schuss",
-14
View File
@@ -17,20 +17,6 @@ pfUI_locale["enUS"]["healduration"] = {
["Renew"] = "Increases the duration of your Renew spell by 3 sec.", ["Renew"] = "Increases the duration of your Renew spell by 3 sec.",
} }
pfUI_locale["enUS"]["bagtypes"] = {
["Quiver"] = "QUIVER",
["Soul Bag"] = "SOULBAG",
["Bag"] = "DEFAULT",
}
pfUI_locale["enUS"]["itemtypes"] = {
["INVTYPE_WAND"] = "Wand",
["INVTYPE_THROWN"] = "Thrown",
["INVTYPE_GUN"] = "Gun",
["INVTYPE_CROSSBOW"] = "Crossbow",
["INVTYPE_PROJECTILE"] = "Projectile",
}
pfUI_locale["enUS"]["customcast"] = { pfUI_locale["enUS"]["customcast"] = {
["AIMEDSHOT"] = "Aimed Shot", ["AIMEDSHOT"] = "Aimed Shot",
["MULTISHOT"] = "Multi-Shot", ["MULTISHOT"] = "Multi-Shot",
-14
View File
@@ -17,20 +17,6 @@ pfUI_locale["esES"]["healduration"] = {
["Renew"] = "Aumenta en 3 s la duración de tu hechizo Renovar.", ["Renew"] = "Aumenta en 3 s la duración de tu hechizo Renovar.",
} }
pfUI_locale["esES"]["bagtypes"] = {
["Carcaj"] = "QUIVER",
["Bolsa de almas"] = "SOULBAG",
["Bolsa"] = "DEFAULT",
}
pfUI_locale["esES"]["itemtypes"] = {
["INVTYPE_WAND"] = "Varita",
["INVTYPE_THROWN"] = "Arma arrojadiza",
["INVTYPE_GUN"] = "Arma de fuego",
["INVTYPE_CROSSBOW"] = "Ballesta",
["INVTYPE_PROJECTILE"] = "Proyectil",
}
pfUI_locale["esES"]["customcast"] = { pfUI_locale["esES"]["customcast"] = {
["AIMEDSHOT"] = "Disparo de puntería", ["AIMEDSHOT"] = "Disparo de puntería",
["MULTISHOT"] = "Multidisparo", ["MULTISHOT"] = "Multidisparo",
-14
View File
@@ -17,20 +17,6 @@ pfUI_locale["frFR"]["healduration"] = {
["Renew"] = "Augmente la durée de votre sort Rénovation de 3 sec.", ["Renew"] = "Augmente la durée de votre sort Rénovation de 3 sec.",
} }
pfUI_locale["frFR"]["bagtypes"] = {
["Carquois"] = "QUIVER",
["Sac d'âme"] = "SOULBAG",
["Conteneur"] = "DEFAULT",
}
pfUI_locale["frFR"]["itemtypes"] = {
["INVTYPE_WAND"] = "Baguette",
["INVTYPE_THROWN"] = "Armes de jet",
["INVTYPE_GUN"] = "Arme à feu",
["INVTYPE_CROSSBOW"] = "Arbalète",
["INVTYPE_PROJECTILE"] = "Projectile",
}
pfUI_locale["frFR"]["customcast"] = { pfUI_locale["frFR"]["customcast"] = {
["AIMEDSHOT"] = "Visée", ["AIMEDSHOT"] = "Visée",
["MULTISHOT"] = "Flèches multiples", ["MULTISHOT"] = "Flèches multiples",
-14
View File
@@ -17,20 +17,6 @@ pfUI_locale["koKR"]["healduration"] = {
["Renew"] = "소생의 지속시간이 3초만큼 증가합니다.", ["Renew"] = "소생의 지속시간이 3초만큼 증가합니다.",
} }
pfUI_locale["koKR"]["bagtypes"] = {
["화살통"] = "QUIVER",
["영혼의 가방"] = "SOULBAG",
["가방"] = "DEFAULT",
}
pfUI_locale["koKR"]["itemtypes"] = {
["INVTYPE_WAND"] = "마법봉",
["INVTYPE_THROWN"] = "투척 무기",
["INVTYPE_GUN"] = "총",
["INVTYPE_CROSSBOW"] = "석궁",
["INVTYPE_PROJECTILE"] = "투사체",
}
pfUI_locale["koKR"]["customcast"] = { pfUI_locale["koKR"]["customcast"] = {
["AIMEDSHOT"] = "조준 사격", ["AIMEDSHOT"] = "조준 사격",
["MULTISHOT"] = "일제 사격", ["MULTISHOT"] = "일제 사격",
-14
View File
@@ -17,20 +17,6 @@ pfUI_locale["ruRU"]["healduration"] = {
["Renew"] = "Продлевает действие \"Обновления\" на 3 сек.", ["Renew"] = "Продлевает действие \"Обновления\" на 3 сек.",
} }
pfUI_locale["ruRU"]["bagtypes"] = {
["Колчан"] = "QUIVER",
["Сумка душ"] = "SOULBAG",
["Сумка"] = "DEFAULT",
}
pfUI_locale["ruRU"]["itemtypes"] = {
["INVTYPE_WAND"] = "Жезл",
["INVTYPE_THROWN"] = "Метательное",
["INVTYPE_GUN"] = "Огнестрельное",
["INVTYPE_CROSSBOW"] = "Арбалет",
["INVTYPE_PROJECTILE"] = "Боеприпасы",
}
pfUI_locale["ruRU"]["customcast"] = { pfUI_locale["ruRU"]["customcast"] = {
["AIMEDSHOT"] = "Прицельный выстрел", ["AIMEDSHOT"] = "Прицельный выстрел",
["MULTISHOT"] = "Залп", ["MULTISHOT"] = "Залп",
-14
View File
@@ -17,20 +17,6 @@ pfUI_locale["zhCN"]["healduration"] = {
["Renew"] = "使你的恢复术的持续时间延长3秒。", ["Renew"] = "使你的恢复术的持续时间延长3秒。",
} }
pfUI_locale["zhCN"]["bagtypes"] = {
["箭袋"] = "QUIVER",
["灵魂袋"] = "SOULBAG",
["容器"] = "DEFAULT",
}
pfUI_locale["zhCN"]["itemtypes"] = {
["INVTYPE_WAND"] = "魔杖",
["INVTYPE_THROWN"] = "投掷武器",
["INVTYPE_GUN"] = "枪械",
["INVTYPE_CROSSBOW"] = "弩",
["INVTYPE_PROJECTILE"] = "弹药",
}
pfUI_locale["zhCN"]["customcast"] = { pfUI_locale["zhCN"]["customcast"] = {
["AIMEDSHOT"] = "瞄准射击", ["AIMEDSHOT"] = "瞄准射击",
["MULTISHOT"] = "多重射击", ["MULTISHOT"] = "多重射击",
+71 -81
View File
@@ -1,10 +1,5 @@
pfUI:RegisterModule("eqcompare", function () pfUI:RegisterModule("eqcompare", function ()
local sides = { "Left", "Right" } local sides = { "Left", "Right" }
local loc = pfUI.cache["locale"]
for key, value in pairs(L["itemtypes"]) do setglobal(key, value) end
INVTYPE_WEAPON_OTHER = INVTYPE_WEAPON.."_other"
INVTYPE_FINGER_OTHER = INVTYPE_FINGER.."_other"
INVTYPE_TRINKET_OTHER = INVTYPE_TRINKET.."_other"
local function AddHeader(tooltip) local function AddHeader(tooltip)
local name = tooltip:GetName() local name = tooltip:GetName()
@@ -46,39 +41,37 @@ pfUI:RegisterModule("eqcompare", function ()
tooltip:Show() tooltip:Show()
end end
-- Numeric slotTable keyed by Enum.InventoryType (from
-- C_Item.GetItemInventoryTypeByID). Pair-slot types (finger / trinket /
-- one-hand weapon) list both destinations so both comparison tooltips
-- can be shown at once.
local slotTable = { local slotTable = {
[INVTYPE_2HWEAPON] = "MainHandSlot", [1] = { "HeadSlot" },
[INVTYPE_BODY] = "ShirtSlot", [2] = { "NeckSlot" },
[INVTYPE_CHEST] = "ChestSlot", [3] = { "ShoulderSlot" },
[INVTYPE_CLOAK] = "BackSlot", [4] = { "ShirtSlot" },
[INVTYPE_FEET] = "FeetSlot", [5] = { "ChestSlot" },
[INVTYPE_FINGER] = "Finger0Slot", [6] = { "WaistSlot" },
[INVTYPE_FINGER_OTHER] = "Finger1Slot", [7] = { "LegsSlot" },
[INVTYPE_HAND] = "HandsSlot", [8] = { "FeetSlot" },
[INVTYPE_HEAD] = "HeadSlot", [9] = { "WristSlot" },
[INVTYPE_HOLDABLE] = "SecondaryHandSlot", [10] = { "HandsSlot" },
[INVTYPE_LEGS] = "LegsSlot", [11] = { "Finger0Slot", "Finger1Slot" },
[INVTYPE_NECK] = "NeckSlot", [12] = { "Trinket0Slot", "Trinket1Slot" },
[INVTYPE_RANGED] = "RangedSlot", [13] = { "MainHandSlot", "SecondaryHandSlot" }, -- one-hand weapon
[INVTYPE_RELIC] = "RangedSlot", [14] = { "SecondaryHandSlot" }, -- shield
[INVTYPE_ROBE] = "ChestSlot", [15] = { "RangedSlot" }, -- ranged (bow)
[INVTYPE_SHIELD] = "SecondaryHandSlot", [16] = { "BackSlot" },
[INVTYPE_SHOULDER] = "ShoulderSlot", [17] = { "MainHandSlot" }, -- two-hand weapon
[INVTYPE_TABARD] = "TabardSlot", [19] = { "TabardSlot" },
[INVTYPE_TRINKET] = "Trinket0Slot", [20] = { "ChestSlot" }, -- robe
[INVTYPE_TRINKET_OTHER] = "Trinket1Slot", [21] = { "MainHandSlot" },
[INVTYPE_WAIST] = "WaistSlot", [22] = { "SecondaryHandSlot" },
[INVTYPE_WEAPON] = "MainHandSlot", [23] = { "SecondaryHandSlot" }, -- holdable (off-hand)
[INVTYPE_WEAPON_OTHER] = "SecondaryHandSlot", [24] = { "AmmoSlot" },
[INVTYPE_WEAPONMAINHAND] = "MainHandSlot", [25] = { "RangedSlot" }, -- thrown
[INVTYPE_WEAPONOFFHAND] = "SecondaryHandSlot", [26] = { "RangedSlot" }, -- ranged-right (wand/gun/crossbow)
[INVTYPE_WRIST] = "WristSlot", [28] = { "RangedSlot" }, -- relic
[INVTYPE_WAND] = "RangedSlot",
[INVTYPE_GUN] = "RangedSlot",
[INVTYPE_PROJECTILE] = "AmmoSlot",
[INVTYPE_CROSSBOW] = "RangedSlot",
[INVTYPE_THROWN] = "RangedSlot",
} }
local function startsWith(str, start) local function startsWith(str, start)
@@ -169,55 +162,52 @@ pfUI:RegisterModule("eqcompare", function ()
pfUI.eqcompare.tooltip = this pfUI.eqcompare.tooltip = this
if not IsShiftKeyDown() and C.tooltip.compare.showalways ~= "1" then return end if not IsShiftKeyDown() and C.tooltip.compare.showalways ~= "1" then return end
local rawborder, border = GetBorderSize()
for i=1,this:NumLines() do -- Resolve the item's slot numerically instead of scanning tooltip text
local tmpText = _G[this:GetName() .. "TextLeft"..i] -- for a localized INVTYPE_* label. GameTooltip:GetItem() returns
for slotType, slotName in pairs(slotTable) do -- (name, link, itemID); the slotTable is keyed by Enum.InventoryType.
if tmpText:GetText() == slotType then local _, _, itemID = this:GetItem()
local slotID = GetInventorySlotInfo(slotTable[slotType]) if not itemID then return end
local invType = C_Item.GetItemInventoryTypeByID(itemID)
local slots = invType and slotTable[invType]
if not slots then return end
-- determine screen part local _, border = GetBorderSize()
local ltrigger = GetScreenWidth() / 2
local x = GetCursorPosition()
x = x / UIParent:GetEffectiveScale()
if x > ltrigger then ltrigger = nil end
-- first tooltip -- determine screen part
ShoppingTooltip1:SetOwner(this, "ANCHOR_NONE") local ltrigger = GetScreenWidth() / 2
ShoppingTooltip1:ClearAllPoints() local x = GetCursorPosition()
x = x / UIParent:GetEffectiveScale()
if x > ltrigger then ltrigger = nil end
if ltrigger then -- first tooltip
ShoppingTooltip1:SetPoint("BOTTOMLEFT", this, "BOTTOMRIGHT", 0, 0) local slotID = GetInventorySlotInfo(slots[1])
else ShoppingTooltip1:SetOwner(this, "ANCHOR_NONE")
ShoppingTooltip1:SetPoint("BOTTOMRIGHT", this, "BOTTOMLEFT", -border*2-1, 0) ShoppingTooltip1:ClearAllPoints()
end if ltrigger then
ShoppingTooltip1:SetPoint("BOTTOMLEFT", this, "BOTTOMRIGHT", 0, 0)
ShoppingTooltip1:SetInventoryItem("player", slotID) else
ShoppingTooltip1:Show() ShoppingTooltip1:SetPoint("BOTTOMRIGHT", this, "BOTTOMLEFT", -border*2-1, 0)
AddHeader(ShoppingTooltip1)
-- second tooltip
if slotTable[slotType .. "_other"] then
local slotID_other = GetInventorySlotInfo(slotTable[slotType .. "_other"])
ShoppingTooltip2:SetOwner(this, "ANCHOR_NONE")
ShoppingTooltip2:ClearAllPoints()
if ltrigger then
ShoppingTooltip2:SetPoint("BOTTOMLEFT", ShoppingTooltip1, "BOTTOMRIGHT", 0, 0)
else
ShoppingTooltip2:SetPoint("BOTTOMRIGHT", ShoppingTooltip1, "BOTTOMLEFT", -border*2-1, 0)
end
ShoppingTooltip2:SetInventoryItem("player", slotID_other)
ShoppingTooltip2:Show()
AddHeader(ShoppingTooltip2)
end
return true
end
end
end end
ShoppingTooltip1:SetInventoryItem("player", slotID)
ShoppingTooltip1:Show()
AddHeader(ShoppingTooltip1)
-- second tooltip for pair slots (finger / trinket / 1H weapon)
if slots[2] then
local slotID_other = GetInventorySlotInfo(slots[2])
ShoppingTooltip2:SetOwner(this, "ANCHOR_NONE")
ShoppingTooltip2:ClearAllPoints()
if ltrigger then
ShoppingTooltip2:SetPoint("BOTTOMLEFT", ShoppingTooltip1, "BOTTOMRIGHT", 0, 0)
else
ShoppingTooltip2:SetPoint("BOTTOMRIGHT", ShoppingTooltip1, "BOTTOMLEFT", -border*2-1, 0)
end
ShoppingTooltip2:SetInventoryItem("player", slotID_other)
ShoppingTooltip2:Show()
AddHeader(ShoppingTooltip2)
end
return true
end end
-- add HookScript method if not already existing -- add HookScript method if not already existing