main.lua 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. local IUI = LibStub("LibItemUpgradeInfo-1.0")
  2. local GREY = {0.55, 0.55, 0.55}
  3. local GREEN = {0, 1, 0}
  4. local WHITE = {1, 1, 1}
  5. -- thank you SyLevel!
  6. local function getItemLink(location)
  7. -- https://www.townlong-yak.com/framexml/27219/EquipmentManager.lua#276
  8. local player, bank, bags, voidStorage, slot, bag, tab, voidSlot = EquipmentManager_UnpackLocation(location)
  9. if ( not player and not bank and not bags and not voidStorage ) then
  10. return
  11. end
  12. if not bags then -- player or bank
  13. return GetInventoryItemLink('player', slot)
  14. else -- bags
  15. return GetContainerItemLink(bag, slot)
  16. end
  17. end
  18. local createText = function(button)
  19. local label = button.GioFlyout
  20. if (not label) then
  21. label = button:CreateFontString(nil,"OVERLAY")
  22. label:SetFont("Fonts\\FRIZQT__.TTF", 14, "OUTLINE")
  23. label:SetPoint("CENTER", button, "CENTER", 0, 0)
  24. button.GioFlyout = label
  25. end
  26. return label
  27. end
  28. local function RelativeColor(ilvl)
  29. --[[local avgItemLevel, avgItemLevelEquipped = GetAverageItemLevel()
  30. local e = math.floor(avgItemLevelEquipped)
  31. if ilvl < e then
  32. return unpack(GREY)
  33. elseif ilvl > e then
  34. return unpack(GREEN)
  35. else
  36. return unpack(WHITE)
  37. end]]
  38. return unpack(WHITE)
  39. end
  40. local function hook_EquipmentFlyout_DisplayButton(button)
  41. -- https://www.townlong-yak.com/framexml/27219/EquipmentFlyout.lua#370
  42. local location = button.location
  43. if (location and location < EQUIPMENTFLYOUT_FIRST_SPECIAL_LOCATION) then
  44. local link = getItemLink(location)
  45. local ilvl = IUI:GetUpgradedItemLevel(link)
  46. local label = createText(button)
  47. label:SetTextColor(RelativeColor(ilvl))
  48. label:SetText(ilvl)
  49. label:Show()
  50. end
  51. end
  52. hooksecurefunc('EquipmentFlyout_DisplayButton', hook_EquipmentFlyout_DisplayButton)
  53. --IUI:GetUpgradedItemLevel(location)