Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2011
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 18.68 KB | None | 0 0
  1. -- InspectEquip
  2.  
  3. InspectEquip = LibStub("AceAddon-3.0"):NewAddon("InspectEquip", "AceConsole-3.0", "AceHook-3.0", "AceTimer-3.0", "AceEvent-3.0")
  4. local L = LibStub("AceLocale-3.0"):GetLocale("InspectEquip")
  5. local IE = InspectEquip
  6. local IS = InspectEquip_ItemSources --> ItemSources.lua
  7. local WIN = InspectEquip_InfoWindow --> InfoWindow.xml
  8. local TITLE = InspectEquip_InfoWindowTitle
  9. local AVGIL = InspectEquip_InfoWindowAvgItemLevel
  10. local exMod = nil
  11.  
  12. local ReforgingInfo = LibStub("LibReforgingInfo-1.0")
  13.  
  14. local slots = { "HeadSlot", "NeckSlot", "ShoulderSlot", "BackSlot", "ChestSlot",
  15.                 "WristSlot", "HandsSlot", "WaistSlot", "LegsSlot", "FeetSlot",
  16.                 "Finger0Slot", "Finger1Slot", "Trinket0Slot", "Trinket1Slot", "MainHandSlot",
  17.                 "SecondaryHandSlot", "RangedSlot" } -- TabardSlot, ShirtSlot
  18. local noEnchantWarningSlots = {
  19.     ["NeckSlot"] = true, ["WaistSlot"] = true, ["Finger0Slot"] = true, ["Finger1Slot"] = true,
  20.     ["Trinket0Slot"] = true, ["Trinket1Slot"] = true, ["SecondaryHandSlot"] = true, ["RangedSlot"] = true,
  21. }
  22.            
  23. local lines = {}
  24. local numlines = 0
  25. local curline = 0
  26. local curUnit = nil
  27. local curUnitName = nil
  28. local curUser = nil
  29. local curGUID = nil
  30. local cached = false
  31.  
  32. local headers = {}
  33. local numheaders = 0
  34.  
  35. local yoffset = -40
  36. local hooked = false
  37. local autoHidden = false
  38.  
  39. local origInspectUnit
  40.  
  41. local tonumber = tonumber
  42. local gmatch = string.gmatch
  43. local tinsert = table.insert
  44. local tsort = table.sort
  45. local band = bit.band
  46. local Examiner = Examiner
  47.  
  48. --local _,_,_,gameToc = GetBuildInfo()
  49.  
  50. local tooltipTimer = nil
  51.  
  52. local dummy_tooltip = CreateFrame("GameTooltip", "dummy_tooltip", UIParent, "GameTooltipTemplate")
  53. dummy_tooltip:SetOwner(WorldFrame, "ANCHOR_NONE")
  54.  
  55.  
  56. --------------------------------------------------------------------------------------
  57.  
  58. InspectEquipConfig = {}
  59. local defaults = {
  60.     tooltips = true,
  61.     showUnknown = true,
  62.     inspectWindow = true,
  63.     charWindow = true,
  64.     checkEnchants = true,
  65.     listItemLevels = true,
  66.     showAvgItemLevel = true,
  67.     ttR = 1.0,
  68.     ttG = 0.75,
  69.     ttB = 0.0,
  70. }
  71.  
  72. local options = {
  73.     name = "InspectEquip",
  74.     type = "group",
  75.     args = {
  76.         tooltips = {
  77.             order = 1, type = "toggle", width = "full",
  78.             name = L["Add drop information to tooltips"],
  79.             desc = L["Add item drop information to all item tooltips"],
  80.             get = function() return InspectEquipConfig.tooltips end,
  81.             set = function(_,v) InspectEquipConfig.tooltips = v; if v then IE:HookTooltips() end end,
  82.         },
  83.         showunknown = {
  84.             order = 2, type = "toggle", width = "full",
  85.             name = L["Include unknown items in overview"],
  86.             desc = L["Show items that cannot be categorized in a seperate category"],
  87.             get = function() return InspectEquipConfig.showUnknown end,
  88.             set = function(_,v) InspectEquipConfig.showUnknown = v end,
  89.         },
  90.         inspectwindow = {
  91.             order = 3, type = "toggle", width = "full",
  92.             name = L["Attach to inspect window"],
  93.             desc = L["Show the equipment list when inspecting other characters"],
  94.             get = function() return InspectEquipConfig.inspectWindow end,
  95.             set = function(_,v) InspectEquipConfig.inspectWindow = v end,
  96.         },
  97.         charwindow = {
  98.             order = 4, type = "toggle", width = "full",
  99.             name = L["Attach to character window"],
  100.             desc = L["Also show the InspectEquip panel when opening the character window"],
  101.             get = function() return InspectEquipConfig.charWindow end,
  102.             set = function(_,v) InspectEquipConfig.charWindow = v end,
  103.         },
  104.         checkenchants = {
  105.             order = 5, type = "toggle", width = "full",
  106.             name = L["Check for unenchanted items"],
  107.             desc = L["Display a warning for unenchanted items"],
  108.             get = function() return InspectEquipConfig.checkEnchants end,
  109.             set = function(_,v) InspectEquipConfig.checkEnchants = v end,
  110.         },
  111.         listitemlevels = {
  112.             order = 6, type = "toggle", width = "full",
  113.             name = L["Show item level in equipment list"],
  114.             desc = L["Show the item level of each item in the equipment panel"],
  115.             get = function() return InspectEquipConfig.listItemLevels end,
  116.             set = function(_,v) InspectEquipConfig.listItemLevels = v end,
  117.         },
  118.         showavgitemlevel = {
  119.             order = 7, type = "toggle", width = "full",
  120.             name = L["Show average item level in equipment list"],
  121.             desc = L["Show the average item level of all items in the equipment panel"],
  122.             get = function() return InspectEquipConfig.showAvgItemLevel end,
  123.             set = function(_,v) InspectEquipConfig.showAvgItemLevel = v end,
  124.         },
  125.         tooltipcolor = {
  126.             order = 7, type = "color",
  127.             name = L["Tooltip text color"],
  128.             get = function() return InspectEquipConfig.ttR, InspectEquipConfig.ttG, InspectEquipConfig.ttB, 1.0 end,
  129.             set = function(_,r,g,b,a)
  130.                 InspectEquipConfig.ttR = r
  131.                 InspectEquipConfig.ttG = g
  132.                 InspectEquipConfig.ttB = b
  133.             end,
  134.         }
  135.     },
  136. }
  137.  
  138. LibStub("AceConfig-3.0"):RegisterOptionsTable("InspectEquip", options)
  139. LibStub("AceConfigDialog-3.0"):AddToBlizOptions("InspectEquip")
  140.  
  141. --------------------------------------------------------------------------------------
  142.  
  143. function IE:OnInitialize()
  144.     setmetatable(InspectEquipConfig, {__index = defaults})
  145.  
  146.     self:SetParent(Examiner or InspectFrame)
  147.     WIN:Hide()
  148.     TITLE:SetText("InspectEquip")
  149.  
  150.     if Examiner and Examiner.CreateModule then
  151.         exMod = Examiner:CreateModule("InspectEquip")
  152.         exMod.OnCacheLoaded = function(s, entry, unit)
  153.             if InspectEquipConfig.inspectWindow then
  154.                 IE:Inspect("cache", entry)
  155.             end
  156.         end
  157.         exMod.OnClearInspect = function(s) WIN:Hide() end
  158.         exMod.OnInspect = function(s, unit)
  159.             if InspectEquipConfig.inspectWindow then
  160.                 IE:SetParent(Examiner); IE:Inspect(unit)
  161.             end
  162.         end
  163.     end
  164.  
  165.     self:RegisterEvent("PLAYER_ENTERING_WORLD")
  166.     self:RegisterEvent("ADDON_LOADED")
  167. end
  168.  
  169. function IE:OnEnable()
  170.     origInspectUnit = origInspectUnit or InspectUnit
  171.     InspectUnit = function(...) IE:InspectUnit(...) end
  172.     self:SecureHookScript(PaperDollFrame, "OnShow", "PaperDollFrame_OnShow")
  173.     self:SecureHookScript(PaperDollFrame, "OnHide", "PaperDollFrame_OnHide")
  174.     if GearManagerDialog then -- 4.0
  175.         self:SecureHookScript(GearManagerDialog, "OnShow", "GearManagerDialog_OnShow")
  176.         self:SecureHookScript(GearManagerDialog, "OnHide", "GearManagerDialog_OnHide")
  177.     end
  178.     if OutfitterFrame then
  179.         self:SecureHookScript(OutfitterFrame, "OnShow", "GearManagerDialog_OnShow")
  180.         self:SecureHookScript(OutfitterFrame, "OnHide", "GearManagerDialog_OnHide")
  181.     end
  182.     self:RegisterEvent("UNIT_INVENTORY_CHANGED")
  183.     self:RegisterEvent("INSPECT_READY")
  184. end
  185.  
  186. function IE:OnDisable()
  187.     InspectUnit = origInspectUnit
  188.     if hooked then
  189.         hooked = false
  190.         self:Unhook("InspectFrame_UnitChanged")
  191.     end
  192.     self:UnhookAll()
  193.     self:UnregisterEvent("UNIT_INVENTORY_CHANGED")
  194.     self:UnregisterEvent("INSPECT_READY")
  195.     self:CancelAllTimers()
  196.     WIN:Hide()
  197. end
  198.  
  199. local entered = false
  200.  
  201. function IE:PLAYER_ENTERING_WORLD()
  202.     entered = true
  203.     self:ScheduleTooltipHook()
  204.     self:UnregisterEvent("PLAYER_ENTERING_WORLD")
  205. end
  206.  
  207. function IE:ADDON_LOADED(e, name)
  208.     if entered then
  209.         self:ScheduleTooltipHook()
  210.     end
  211. end
  212.  
  213. -- Ugly hack, but some addons override the OnTooltipSetItem handler on
  214. -- ItemRefTooltip, breaking IE. Using this timer, IE hopefully hooks after them.
  215. function IE:ScheduleTooltipHook()
  216.     if InspectEquipConfig.tooltips then
  217.         if tooltipTimer then
  218.             self:CancelTimer(tooltipTimer, true)
  219.         end
  220.         tooltipTimer = self:ScheduleTimer('HookTooltips', 3)
  221.     end
  222. end
  223.  
  224. function IE:SetParent(frame)
  225.     WIN:SetParent(frame)
  226.     WIN:ClearAllPoints()
  227.     if not (frame == Examiner) then
  228.         WIN:SetPoint("TOPLEFT", frame, "TOPRIGHT", 5, 0)
  229.     else
  230.         WIN:SetPoint("TOPLEFT", frame, "TOPRIGHT", -25, -13)
  231.     end
  232. end
  233.  
  234. function IE:NewLine()
  235.     local row = CreateFrame("Frame", nil, WIN)
  236.     row:SetHeight(12)
  237.     row:SetWidth(200)
  238.     row:SetPoint("TOPLEFT", WIN, "TOPLEFT", 15, yoffset)
  239.  
  240.     local txt = row:CreateFontString(nil, "ARTWORK")
  241.     txt:SetJustifyH("LEFT")
  242.     txt:SetFontObject(GameFontHighlightSmall)
  243.     txt:SetPoint("TOPLEFT", row, "TOPLEFT", 0, 0)
  244.    
  245.     row.text = txt
  246.     yoffset = yoffset - 15
  247.     numlines = numlines + 1
  248.     lines[numlines] = row
  249.    
  250.     row:EnableMouse(true)
  251.     row:SetScript("OnEnter", IE.Line_OnEnter)
  252.     row:SetScript("OnLeave", IE.Line_OnLeave)
  253.     row:SetScript("OnMouseDown", IE.Line_OnClick)
  254. end
  255.  
  256. function IE:ResetDisplay()
  257.     for i = 1, numlines do
  258.         lines[i].text:SetText("")
  259.         lines[i]:Hide()
  260.     end
  261.     curline = 0
  262. end
  263.  
  264. function IE:AddLine(text, link, item)
  265.     curline = curline + 1
  266.     if curline > numlines then
  267.         self:NewLine()
  268.     end
  269.     local line = lines[curline]
  270.     line.link = link
  271.     line.item = item
  272.     line.text:SetText(text)
  273.     line:SetWidth(line.text:GetStringWidth())
  274.     line:SetFrameLevel(WIN:GetFrameLevel() + 1)
  275.     line:Show()
  276. end
  277.  
  278. function IE:FullUnitName(name, realm)
  279.     if realm and realm ~= "" then
  280.         return name .. "-" .. realm
  281.     else
  282.         return name
  283.     end
  284. end
  285.  
  286. function IE:GetExaminerCache(unit)
  287.     local name, realm = UnitName(unit)
  288.     return Examiner_Cache and Examiner_Cache[self:FullUnitName(name, realm)]
  289. end
  290.  
  291. function IE:InspectUnit(unit, ...)
  292.     origInspectUnit(unit, ...)
  293.  
  294.     if InspectEquipConfig.inspectWindow then
  295.         self:SetParent(Examiner or InspectFrame)
  296.         WIN:Hide()
  297.         if not hooked and InspectFrame_UnitChanged then
  298.             hooked = true
  299.             self:SecureHook("InspectFrame_UnitChanged")
  300.         end
  301.  
  302.         self:Inspect(unit)
  303.     end
  304. end
  305.  
  306. function IE:InspectFrame_UnitChanged()
  307.     if InspectFrame.unit and InspectEquipConfig.inspectWindow then
  308.         self:InspectUnit(InspectFrame.unit)
  309.     else
  310.         WIN:Hide()
  311.     end
  312. end
  313.  
  314. function IE:PaperDollFrame_OnShow()
  315.     if InspectEquipConfig.charWindow then
  316.         IE:SetParent(CharacterFrame)
  317.         IE:Inspect("player")
  318.     end
  319. end
  320.  
  321. function IE:PaperDollFrame_OnHide()
  322.     if WIN:GetParent() == CharacterFrame then
  323.         WIN:Hide()
  324.         autoHidden = false
  325.     end
  326. end
  327.  
  328. function IE:GearManagerDialog_OnShow()
  329.     if WIN:GetParent() == CharacterFrame and WIN:IsShown() then
  330.         WIN:Hide()
  331.         autoHidden = true
  332.     end
  333. end
  334.  
  335. function IE:GearManagerDialog_OnHide()
  336.     if autoHidden and WIN:GetParent() == CharacterFrame then
  337.         WIN:Show()
  338.         autoHidden = false
  339.     end
  340. end
  341.  
  342. function IE:UNIT_INVENTORY_CHANGED(event, unit)
  343.     if (unit == "player") and (WIN:IsVisible() or autoHidden) and (WIN:GetParent() == CharacterFrame) then
  344.         IE:Inspect("player")
  345.     elseif (unit == curUnit) and (UnitName(unit) == curUnitName) and (WIN:IsVisible()) then
  346.         IE:Inspect(curUnit)
  347.     end
  348. end
  349.  
  350. function IE:INSPECT_READY(event, guid)
  351.     if (guid == curGUID) and (UnitName(curUnit) == curUnitName) and (WIN:IsVisible()) then
  352.         IE:Inspect(curUnit)
  353.     else
  354.         -- probably mouseover changed... nothing we can do apparently :(
  355.     -- (inspect by unit name / guid does not work)
  356.     end
  357. end
  358.  
  359. function IE:Inspect(unit, entry)
  360.     local unitName, unitRealm
  361.     cached = (unit == "cache")
  362.  
  363.     if (cached and (not entry)) or (not self:IsEnabled()) then
  364.         WIN:Hide()
  365.         return
  366.     end
  367.  
  368.     local cacheItems = cached and entry.Items or nil
  369.  
  370.     if cached then
  371.         unitName, unitRealm = entry.name, entry.realm
  372.         curGUID = nil
  373.     else
  374.         if (not unit or not UnitExists(unit)) then
  375.             unit = "player"
  376.         end
  377.         unitName, unitRealm = UnitName(unit)
  378.         curGUID = UnitGUID(unit)
  379.  
  380.         if not CanInspect(unit) then
  381.             entry = self:GetExaminerCache(unit)
  382.             if entry then
  383.                 cached = true
  384.                 cacheItems = entry.Items
  385.             end
  386.         else
  387.             --ClearInspectPlayer()
  388.             --NotifyInspect(unit)
  389.         end
  390.     end
  391.     if unitRealm == "" then unitRealm = nil end
  392.     curUnit = unit
  393.     curUnitName = unitName
  394.     curUser = self:FullUnitName(unitName, unitRealm)
  395.     TITLE:SetText("InspectEquip: " .. curUser .. (cached and " (Cache)" or ""))
  396.  
  397.     self:ResetDisplay()
  398.  
  399.     local items = { cats = {}, items = {} }
  400.     local itemsFound = false
  401.     local getItem
  402.     if cached then
  403.         getItem = function(slot)
  404.             local istr = cacheItems[slot]
  405.             if istr then
  406.                 local itemId = tonumber(istr:match("item:(%d+)"))
  407.                 return select(2, GetItemInfo(istr)) or ("[" .. itemId .. "]")
  408.             else
  409.                 return nil
  410.             end
  411.         end
  412.     else
  413.         getItem = function(slot) return GetInventoryItemLink(unit, GetInventorySlotInfo(slot)) end
  414.     end
  415.  
  416.     local calciv = InspectEquipConfig.showAvgItemLevel
  417.     local iLevelSum, iCount = 0,0
  418.  
  419.     for _,slot in pairs(slots) do
  420.         local itemLink = getItem(slot)
  421.         if itemLink then
  422.             -- get source
  423.             local source = self:GetItemSourceCategories(itemLink)
  424.             if (not source) and InspectEquipConfig.showUnknown then
  425.                 local _,_,rar = GetItemInfo(itemLink)
  426.                 if rar >= 2 then
  427.                     source = {L["Unknown"]}
  428.                 end
  429.             end
  430.            
  431.             if source then
  432.                 local enchantId = tonumber(itemLink:match("Hitem:%d+:(%d+):"))
  433.                 local reforgeId = ReforgingInfo:GetReforgeID(itemLink)
  434.                 local reforgeText = nil
  435.                 if reforgeId then
  436.                     local refid1,refid2 = ReforgingInfo:GetReforgedStatShortNames(reforgeId)
  437.                     reforgeText = " |cff00cc00[" .. string.sub(refid1, 1, 2) .. ">" .. string.sub(refid2, 1, 2) .. "]|r"
  438.                 end
  439.                 itemsFound = true
  440.                
  441.                 -- find category
  442.                 local cat = items
  443.                 local entry
  444.                 for _, entry in pairs(source) do
  445.                     if cat.cats[entry] == nil then
  446.                         cat.cats[entry] = { count = 0, cats = {}, items = {} }
  447.                     end
  448.                     cat = cat.cats[entry]
  449.                     cat.count = cat.count + 1
  450.                 end
  451.                
  452.                 -- add item to category
  453.                 cat.hasItems = true
  454.                 cat.items[cat.count] = {link = itemLink, enchant = enchantId, reforged = reforgeText, slot = slot}
  455.             end
  456.            
  457.             -- calculate avg ilvl
  458.             if calciv then
  459.                 local _,_,rar,lvl = GetItemInfo(itemLink)
  460.                 if lvl then
  461.                     iLevelSum = iLevelSum + lvl
  462.                     iCount = iCount + 1
  463.                 end
  464.             end
  465.        
  466.         end
  467.     end
  468.  
  469.     if itemsFound then
  470.         self:AddCategory(items, "")
  471.         if calciv and iCount > 0 then
  472.             local avgLvl = iLevelSum / iCount
  473.             AVGIL:SetText(L["Avg. Item Level"] .. ": " .. string.format("%.2f", avgLvl))
  474.             AVGIL:Show()
  475.         else
  476.             AVGIL:Hide()
  477.         end
  478.         self:FixWindowSize()
  479.         if WIN:GetParent() == CharacterFrame and ((GearManagerDialog and GearManagerDialog:IsVisible()) or (OutfitterFrame and OutfitterFrame:IsVisible())) then
  480.             autoHidden = true
  481.         else
  482.             WIN:Show()
  483.         end
  484.     else
  485.         WIN:Hide()
  486.     end
  487. end
  488.  
  489. function IE:AddCategory(cat, prefix)
  490.     -- add items
  491.     if #cat.items > 0 then
  492.         self:AddItems(cat.items, prefix .. "  ")
  493.     end
  494.    
  495.     -- sort subcategories by item count
  496.     local t = {}
  497.     for name, subcat in pairs(cat.cats) do
  498.         tinsert(t, {name = name, subcat = subcat})
  499.     end
  500.     tsort(t, function(a,b) return a.subcat.count > b.subcat.count end)
  501.    
  502.     -- add subcategories
  503.     for i = 1, #t do
  504.         local name = t[i].name
  505.         local subcat = t[i].subcat
  506.         self:AddLine(prefix .. name .. " (" .. subcat.count .. ")")
  507.         self:AddCategory(subcat, prefix .. "  ")
  508.     end
  509. end
  510.  
  511. function IE:AddItems(tab, padding)
  512.     for _, item in pairs(tab) do
  513.         local suffix = ""
  514.         local prefix = padding
  515.         if InspectEquipConfig.listItemLevels then
  516.             local _,_,_,ilvl = GetItemInfo(item.link)
  517.             if ilvl then
  518.                 prefix = padding .. "|cffaaaaaa[" .. ilvl .. "]|r "
  519.             end
  520.         end
  521.         if InspectEquipConfig.checkEnchants and (item.enchant == 0) and (not noEnchantWarningSlots[item.slot]) then
  522.             suffix = "|cffff0000*|r"
  523.         end
  524.         -- set tooltip used for gem+bonus scanning
  525.         dummy_tooltip:ClearLines()
  526.         dummy_tooltip:SetHyperlink(item.link)
  527.         -- if it does have a socket bonus, check for empty gems
  528.         for i = 1, 4 do
  529.             local gemtexture = _G["dummy_tooltipTexture"..i]
  530.             -- if the gem is empty, add to label text
  531.             if gemtexture and gemtexture:IsVisible() and string.find(gemtexture:GetTexture(), "Empty") then
  532.                 suffix = suffix .. " |cff00ff00*|r"
  533.                 break
  534.             end
  535.         end
  536.         -- and iterate over the lines
  537.         for i = 1, dummy_tooltip:NumLines() do
  538.             -- check the text for socket bonus
  539.             local line = _G["dummy_tooltipTextLeft" .. i]
  540.             if line and line:GetText() and string.find(line:GetText(), "Socket Bonus: ") then -- this won't be localised!
  541.                 -- if the socket bonus isn't the right colour (it not gemmed for socket bonus) add text
  542.                 if line:GetTextColor() ~= 0 then
  543.                     suffix = suffix .. " |cffffa500*|r"
  544.                     break
  545.                 end
  546.             end
  547.         end
  548.     if item.reforged then
  549.         suffix = suffix .. item.reforged
  550.     end
  551.         self:AddLine(prefix .. item.link .. suffix, item.link, item)
  552.     end
  553. end
  554.  
  555. function IE:GetItemData(item)
  556.     local id
  557.     if type(item) == "number" then
  558.         id = item
  559.     else -- item string/link
  560.         id = tonumber(item:match("item:(%d+)"))
  561.     end
  562.    
  563.     if id then
  564.         return IS.Items[id]
  565.     else
  566.         return nil
  567.     end
  568. end
  569.  
  570. function IE:GetItemSourceCategories(itemLink)
  571.     local data = IE:GetItemData(itemLink)
  572.     if data then
  573.         for entry in gmatch(data, "[^;]+") do
  574.             local next_field = gmatch(entry, "[^_]+")
  575.             local cat = next_field()
  576.            
  577.             if cat == "r" or cat == "d" then
  578.                 -- raid/dungeon
  579.                 local zone = IS.Zones[tonumber(next_field())]
  580.                 local mode = next_field()
  581.                 local zoneType
  582.                 if cat == "r" then zoneType = L["Raid"] else zoneType = L["Instances"] end
  583.                 return {zoneType, zone}
  584.             elseif cat == "v" or cat == "g" then
  585.                 -- vendor
  586.                 local mainCat
  587.                 if cat == "v" then mainCat = L["Vendor"] else mainCat = L["Guild Vendor"] end
  588.                 local typ = next_field()
  589.                 while typ do
  590.                     if typ == "c" then
  591.                         -- currency
  592.                         local currency = tonumber(next_field())
  593.                         next_field()
  594.                         local curName = GetCurrencyInfo(currency)
  595.                         return {mainCat, curName}
  596.                     elseif typ == "i" then
  597.                         -- item
  598.                         next_field()
  599.                     elseif typ == "m" then
  600.                         -- money
  601.                         next_field()
  602.                     end
  603.                     typ = next_field()
  604.                 end
  605.                 return {mainCat}
  606.             elseif cat == "f" then
  607.                 -- reputation rewards
  608.                 return {L["Reputation rewards"]}
  609.             elseif cat == "m" then
  610.                 -- darkmoon cards
  611.                 return {L["Darkmoon Faire"]}
  612.             elseif cat == "w" then
  613.                 -- world drops
  614.                 return {L["World drops"]}
  615.             elseif cat == "c" then
  616.                 -- crafted
  617.                 return {L["Crafted"]}
  618.             end
  619.            
  620.         end
  621.     end
  622.     return nil
  623. end
  624.  
  625. function IE:FixWindowSize()
  626.     local maxwidth = TITLE:GetStringWidth()
  627.     for i = 1, numlines do
  628.         local width = lines[i].text:GetStringWidth()
  629.         if maxwidth < width then maxwidth = width end
  630.     end
  631.     local height = (curline * 15) + 55
  632.     if InspectEquipConfig.showAvgItemLevel then
  633.         height = height + 15
  634.     end
  635.     WIN:SetWidth(maxwidth + 40)
  636.     WIN:SetHeight(height)
  637. end
  638.  
  639. function IE.Line_OnEnter(row)
  640.     if row.link then
  641.         GameTooltip:SetOwner(WIN, "ANCHOR_RIGHT")
  642.         if (not cached) and (UnitName(curUnit) == curUnitName) then
  643.             row.link = GetInventoryItemLink(curUnit, GetInventorySlotInfo(row.item.slot)) or row.link
  644.         end
  645.         GameTooltip:SetHyperlink(row.link)
  646.         if row.item and InspectEquipConfig.checkEnchants and (row.item.enchant == 0) and (not noEnchantWarningSlots[row.item.slot]) then
  647.             GameTooltip:AddLine(" ")
  648.             GameTooltip:AddLine("|cffff0000" .. L["Item is not enchanted"] .. "|r")
  649.         end
  650.         GameTooltip:Show()
  651.     end
  652. end
  653.  
  654. function IE.Line_OnLeave(row)
  655.     GameTooltip:Hide()
  656. end
  657.  
  658. function IE.Line_OnClick(row, button)
  659.     if row.link then
  660.         if IsControlKeyDown() then
  661.             DressUpItemLink(row.link)
  662.         elseif IsShiftKeyDown() then
  663.             ChatEdit_InsertLink(row.link)
  664.         end
  665.     end
  666. end
  667.  
  668.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement