mirror of
https://github.com/brues-code/pfUI.git
synced 2026-09-24 00:26:55 +00:00
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:
+12
-12
@@ -28,12 +28,8 @@ function pfUI.api.HasNampower()
|
||||
return GetNampowerVersion and true or false
|
||||
end
|
||||
|
||||
local isTurtleWoW
|
||||
function pfUI.api.IsTurtleWoW()
|
||||
if isTurtleWoW == nil then
|
||||
isTurtleWoW = C_Spell.GetSpellTexture(46050) == "Interface\\Icons\\Trade_Survival"
|
||||
end
|
||||
return isTurtleWoW
|
||||
return C_Spell.GetSpellTexture(46050) == "Interface\\Icons\\Trade_Survival"
|
||||
end
|
||||
|
||||
-- [ GetUnitDistance ]
|
||||
@@ -434,13 +430,17 @@ function pfUI.api.GetBagFamily(bag)
|
||||
|
||||
local id = GetInventoryItemID("player", ContainerIDToInventoryID(bag))
|
||||
if id then
|
||||
local _, _, _, _, _, itemType, subType = GetItemInfo(id)
|
||||
local bagsubtype = L["bagtypes"][subType]
|
||||
|
||||
if bagsubtype == "DEFAULT" then return "BAG" end
|
||||
if bagsubtype == "SOULBAG" then return "SOULBAG" end
|
||||
if bagsubtype == "QUIVER" then return "QUIVER" end
|
||||
if bagsubtype == nil then return "SPECIAL" end
|
||||
-- classID 1 = Container (bags), 11 = Quiver
|
||||
-- Container subclasses: 0 = Bag (default), 1 = Soul Bag, 2+ = specialty (herb/enchanting/etc.)
|
||||
-- Quiver subclasses: 2 = Quiver (arrows), 3 = Ammo Pouch (bullets)
|
||||
local _, _, _, _, _, classID, subClassID = C_Item.GetItemInfoInstant(id)
|
||||
if classID == 1 then
|
||||
if subClassID == 0 then return "BAG" end
|
||||
if subClassID == 1 then return "SOULBAG" end
|
||||
return "SPECIAL"
|
||||
elseif classID == 11 then
|
||||
return "QUIVER"
|
||||
end
|
||||
end
|
||||
|
||||
return nil
|
||||
|
||||
Vendored
-14
@@ -17,20 +17,6 @@ pfUI_locale["deDE"]["healduration"] = {
|
||||
["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"] = {
|
||||
["AIMEDSHOT"] = "Gezielter Schuss",
|
||||
["MULTISHOT"] = "Mehrfach-Schuss",
|
||||
|
||||
Vendored
-14
@@ -17,20 +17,6 @@ pfUI_locale["enUS"]["healduration"] = {
|
||||
["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"] = {
|
||||
["AIMEDSHOT"] = "Aimed Shot",
|
||||
["MULTISHOT"] = "Multi-Shot",
|
||||
|
||||
Vendored
-14
@@ -17,20 +17,6 @@ pfUI_locale["esES"]["healduration"] = {
|
||||
["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"] = {
|
||||
["AIMEDSHOT"] = "Disparo de puntería",
|
||||
["MULTISHOT"] = "Multidisparo",
|
||||
|
||||
Vendored
-14
@@ -17,20 +17,6 @@ pfUI_locale["frFR"]["healduration"] = {
|
||||
["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"] = {
|
||||
["AIMEDSHOT"] = "Visée",
|
||||
["MULTISHOT"] = "Flèches multiples",
|
||||
|
||||
Vendored
-14
@@ -17,20 +17,6 @@ pfUI_locale["koKR"]["healduration"] = {
|
||||
["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"] = {
|
||||
["AIMEDSHOT"] = "조준 사격",
|
||||
["MULTISHOT"] = "일제 사격",
|
||||
|
||||
Vendored
-14
@@ -17,20 +17,6 @@ pfUI_locale["ruRU"]["healduration"] = {
|
||||
["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"] = {
|
||||
["AIMEDSHOT"] = "Прицельный выстрел",
|
||||
["MULTISHOT"] = "Залп",
|
||||
|
||||
Vendored
-14
@@ -17,20 +17,6 @@ pfUI_locale["zhCN"]["healduration"] = {
|
||||
["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"] = {
|
||||
["AIMEDSHOT"] = "瞄准射击",
|
||||
["MULTISHOT"] = "多重射击",
|
||||
|
||||
+71
-81
@@ -1,10 +1,5 @@
|
||||
pfUI:RegisterModule("eqcompare", function ()
|
||||
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 name = tooltip:GetName()
|
||||
@@ -46,39 +41,37 @@ pfUI:RegisterModule("eqcompare", function ()
|
||||
tooltip:Show()
|
||||
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 = {
|
||||
[INVTYPE_2HWEAPON] = "MainHandSlot",
|
||||
[INVTYPE_BODY] = "ShirtSlot",
|
||||
[INVTYPE_CHEST] = "ChestSlot",
|
||||
[INVTYPE_CLOAK] = "BackSlot",
|
||||
[INVTYPE_FEET] = "FeetSlot",
|
||||
[INVTYPE_FINGER] = "Finger0Slot",
|
||||
[INVTYPE_FINGER_OTHER] = "Finger1Slot",
|
||||
[INVTYPE_HAND] = "HandsSlot",
|
||||
[INVTYPE_HEAD] = "HeadSlot",
|
||||
[INVTYPE_HOLDABLE] = "SecondaryHandSlot",
|
||||
[INVTYPE_LEGS] = "LegsSlot",
|
||||
[INVTYPE_NECK] = "NeckSlot",
|
||||
[INVTYPE_RANGED] = "RangedSlot",
|
||||
[INVTYPE_RELIC] = "RangedSlot",
|
||||
[INVTYPE_ROBE] = "ChestSlot",
|
||||
[INVTYPE_SHIELD] = "SecondaryHandSlot",
|
||||
[INVTYPE_SHOULDER] = "ShoulderSlot",
|
||||
[INVTYPE_TABARD] = "TabardSlot",
|
||||
[INVTYPE_TRINKET] = "Trinket0Slot",
|
||||
[INVTYPE_TRINKET_OTHER] = "Trinket1Slot",
|
||||
[INVTYPE_WAIST] = "WaistSlot",
|
||||
[INVTYPE_WEAPON] = "MainHandSlot",
|
||||
[INVTYPE_WEAPON_OTHER] = "SecondaryHandSlot",
|
||||
[INVTYPE_WEAPONMAINHAND] = "MainHandSlot",
|
||||
[INVTYPE_WEAPONOFFHAND] = "SecondaryHandSlot",
|
||||
[INVTYPE_WRIST] = "WristSlot",
|
||||
|
||||
[INVTYPE_WAND] = "RangedSlot",
|
||||
[INVTYPE_GUN] = "RangedSlot",
|
||||
[INVTYPE_PROJECTILE] = "AmmoSlot",
|
||||
[INVTYPE_CROSSBOW] = "RangedSlot",
|
||||
[INVTYPE_THROWN] = "RangedSlot",
|
||||
[1] = { "HeadSlot" },
|
||||
[2] = { "NeckSlot" },
|
||||
[3] = { "ShoulderSlot" },
|
||||
[4] = { "ShirtSlot" },
|
||||
[5] = { "ChestSlot" },
|
||||
[6] = { "WaistSlot" },
|
||||
[7] = { "LegsSlot" },
|
||||
[8] = { "FeetSlot" },
|
||||
[9] = { "WristSlot" },
|
||||
[10] = { "HandsSlot" },
|
||||
[11] = { "Finger0Slot", "Finger1Slot" },
|
||||
[12] = { "Trinket0Slot", "Trinket1Slot" },
|
||||
[13] = { "MainHandSlot", "SecondaryHandSlot" }, -- one-hand weapon
|
||||
[14] = { "SecondaryHandSlot" }, -- shield
|
||||
[15] = { "RangedSlot" }, -- ranged (bow)
|
||||
[16] = { "BackSlot" },
|
||||
[17] = { "MainHandSlot" }, -- two-hand weapon
|
||||
[19] = { "TabardSlot" },
|
||||
[20] = { "ChestSlot" }, -- robe
|
||||
[21] = { "MainHandSlot" },
|
||||
[22] = { "SecondaryHandSlot" },
|
||||
[23] = { "SecondaryHandSlot" }, -- holdable (off-hand)
|
||||
[24] = { "AmmoSlot" },
|
||||
[25] = { "RangedSlot" }, -- thrown
|
||||
[26] = { "RangedSlot" }, -- ranged-right (wand/gun/crossbow)
|
||||
[28] = { "RangedSlot" }, -- relic
|
||||
}
|
||||
|
||||
local function startsWith(str, start)
|
||||
@@ -169,55 +162,52 @@ pfUI:RegisterModule("eqcompare", function ()
|
||||
pfUI.eqcompare.tooltip = this
|
||||
|
||||
if not IsShiftKeyDown() and C.tooltip.compare.showalways ~= "1" then return end
|
||||
local rawborder, border = GetBorderSize()
|
||||
|
||||
for i=1,this:NumLines() do
|
||||
local tmpText = _G[this:GetName() .. "TextLeft"..i]
|
||||
for slotType, slotName in pairs(slotTable) do
|
||||
if tmpText:GetText() == slotType then
|
||||
local slotID = GetInventorySlotInfo(slotTable[slotType])
|
||||
-- Resolve the item's slot numerically instead of scanning tooltip text
|
||||
-- for a localized INVTYPE_* label. GameTooltip:GetItem() returns
|
||||
-- (name, link, itemID); the slotTable is keyed by Enum.InventoryType.
|
||||
local _, _, itemID = this:GetItem()
|
||||
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 ltrigger = GetScreenWidth() / 2
|
||||
local x = GetCursorPosition()
|
||||
x = x / UIParent:GetEffectiveScale()
|
||||
if x > ltrigger then ltrigger = nil end
|
||||
local _, border = GetBorderSize()
|
||||
|
||||
-- first tooltip
|
||||
ShoppingTooltip1:SetOwner(this, "ANCHOR_NONE")
|
||||
ShoppingTooltip1:ClearAllPoints()
|
||||
-- determine screen part
|
||||
local ltrigger = GetScreenWidth() / 2
|
||||
local x = GetCursorPosition()
|
||||
x = x / UIParent:GetEffectiveScale()
|
||||
if x > ltrigger then ltrigger = nil end
|
||||
|
||||
if ltrigger then
|
||||
ShoppingTooltip1:SetPoint("BOTTOMLEFT", this, "BOTTOMRIGHT", 0, 0)
|
||||
else
|
||||
ShoppingTooltip1:SetPoint("BOTTOMRIGHT", this, "BOTTOMLEFT", -border*2-1, 0)
|
||||
end
|
||||
|
||||
ShoppingTooltip1:SetInventoryItem("player", slotID)
|
||||
ShoppingTooltip1:Show()
|
||||
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
|
||||
-- first tooltip
|
||||
local slotID = GetInventorySlotInfo(slots[1])
|
||||
ShoppingTooltip1:SetOwner(this, "ANCHOR_NONE")
|
||||
ShoppingTooltip1:ClearAllPoints()
|
||||
if ltrigger then
|
||||
ShoppingTooltip1:SetPoint("BOTTOMLEFT", this, "BOTTOMRIGHT", 0, 0)
|
||||
else
|
||||
ShoppingTooltip1:SetPoint("BOTTOMRIGHT", this, "BOTTOMLEFT", -border*2-1, 0)
|
||||
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
|
||||
|
||||
-- add HookScript method if not already existing
|
||||
|
||||
Reference in New Issue
Block a user