feat: enhance item tooltips with item level, equip slot, and subclass

Replace minimal name-only item tooltips with proper WoW-style display:
- Quality-colored item name header
- Item level line for equipment (gold text)
- Equip slot and weapon/armor type on a double line
  (e.g., "Head" / "Plate" or "One-Hand" / "Sword")
- Item class for non-equipment items

Shared _WoweePopulateItemTooltip() helper used by both
SetInventoryItem and SetBagItem for consistent tooltip formatting.
Maps INVTYPE_* strings to display names (Head, Chest, Two-Hand, etc.).
This commit is contained in:
Kelsi 2026-03-22 18:02:46 -07:00
parent 101ea9fd17
commit e72d6ad852

View file

@ -5225,6 +5225,37 @@ void LuaEngine::registerCoreAPI() {
" if name then self:SetText(name, 1, 1, 1) end\n"
" end\n"
"end\n"
// Shared item tooltip builder using GetItemInfo return values
"function _WoweePopulateItemTooltip(self, itemId)\n"
" local name, itemLink, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, sellPrice = GetItemInfo(itemId)\n"
" if not name then return false end\n"
" local qColors = {[0]={0.62,0.62,0.62},[1]={1,1,1},[2]={0.12,1,0},[3]={0,0.44,0.87},[4]={0.64,0.21,0.93},[5]={1,0.5,0},[6]={0.9,0.8,0.5},[7]={0,0.8,1}}\n"
" local c = qColors[quality or 1] or {1,1,1}\n"
" self:SetText(name, c[1], c[2], c[3])\n"
" -- Item level for equipment\n"
" if equipSlot and equipSlot ~= '' and iLevel and iLevel > 0 then\n"
" self:AddLine('Item Level '..iLevel, 1, 0.82, 0)\n"
" end\n"
" -- Equip slot and subclass on same line\n"
" if equipSlot and equipSlot ~= '' then\n"
" local slotNames = {INVTYPE_HEAD='Head',INVTYPE_NECK='Neck',INVTYPE_SHOULDER='Shoulder',\n"
" INVTYPE_CHEST='Chest',INVTYPE_WAIST='Waist',INVTYPE_LEGS='Legs',INVTYPE_FEET='Feet',\n"
" INVTYPE_WRIST='Wrist',INVTYPE_HAND='Hands',INVTYPE_FINGER='Finger',\n"
" INVTYPE_TRINKET='Trinket',INVTYPE_CLOAK='Back',INVTYPE_WEAPON='One-Hand',\n"
" INVTYPE_SHIELD='Off Hand',INVTYPE_2HWEAPON='Two-Hand',INVTYPE_RANGED='Ranged',\n"
" INVTYPE_WEAPONMAINHAND='Main Hand',INVTYPE_WEAPONOFFHAND='Off Hand',\n"
" INVTYPE_HOLDABLE='Held In Off-Hand',INVTYPE_TABARD='Tabard',INVTYPE_ROBE='Chest'}\n"
" local slotText = slotNames[equipSlot] or ''\n"
" local subText = (subclass and subclass ~= '') and subclass or ''\n"
" if slotText ~= '' or subText ~= '' then\n"
" self:AddDoubleLine(slotText, subText, 1,1,1, 1,1,1)\n"
" end\n"
" elseif class and class ~= '' then\n"
" self:AddLine(class, 1, 1, 1)\n"
" end\n"
" self.__itemId = itemId\n"
" return true\n"
"end\n"
"function GameTooltip:SetInventoryItem(unit, slot)\n"
" self:ClearLines()\n"
" if unit ~= 'player' then return false, false, 0 end\n"
@ -5232,15 +5263,8 @@ void LuaEngine::registerCoreAPI() {
" if not link then return false, false, 0 end\n"
" local id = link:match('item:(%d+)')\n"
" if not id then return false, false, 0 end\n"
" local name, itemLink, quality, iLevel, reqLevel, class, subclass = GetItemInfo(tonumber(id))\n"
" if name then\n"
" local colors = {[0]={0.62,0.62,0.62},[1]={1,1,1},[2]={0.12,1,0},[3]={0,0.44,0.87},[4]={0.64,0.21,0.93},[5]={1,0.5,0},[6]={0.9,0.8,0.5}}\n"
" local c = colors[quality or 1] or {1,1,1}\n"
" self:SetText(name, c[1], c[2], c[3])\n"
" if class and class ~= '' then self:AddLine(class, 1, 1, 1) end\n"
" self.__itemId = tonumber(id)\n"
" end\n"
" return true, false, 0\n"
" local ok = _WoweePopulateItemTooltip(self, tonumber(id))\n"
" return ok or false, false, 0\n"
"end\n"
"function GameTooltip:SetBagItem(bag, slot)\n"
" self:ClearLines()\n"
@ -5248,14 +5272,8 @@ void LuaEngine::registerCoreAPI() {
" if not link then return end\n"
" local id = link:match('item:(%d+)')\n"
" if not id then return end\n"
" local name, itemLink, q = GetItemInfo(tonumber(id))\n"
" if name then\n"
" local colors = {[0]={0.62,0.62,0.62},[1]={1,1,1},[2]={0.12,1,0},[3]={0,0.44,0.87},[4]={0.64,0.21,0.93},[5]={1,0.5,0}}\n"
" local c = colors[q or 1] or {1,1,1}\n"
" self:SetText(name, c[1], c[2], c[3])\n"
" if count and count > 1 then self:AddLine('Count: '..count, 1, 1, 1) end\n"
" self.__itemId = tonumber(id)\n"
" end\n"
" _WoweePopulateItemTooltip(self, tonumber(id))\n"
" if count and count > 1 then self:AddLine('Count: '..count, 0.5, 0.5, 0.5) end\n"
"end\n"
"function GameTooltip:SetSpellByID(spellId)\n"
" self:ClearLines()\n"