Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --######################
- -- Interface: 40300
- -- Title: QualityID
- -- Notes: Displays an items basic info in the color of the item's quality, in the tooltip.
- -- License: GNUv2GPL
- -- Author: Anaral
- -- Version: 3.20
- --#######################
- QualityID = {}
- QIDDB = {
- enabled = true;
- showid = true;
- showitemLvl = true;
- showStackCount = true;
- showIcon = true;
- showType = true;
- addTopLine = true;
- addBotLine = true;
- QualityIDVersion = "3.2";
- };
- QIDDB.enabled = true
- QIDDB.showid = true
- QIDDB.showitemLvl = true
- QIDDB.showStackCount = true
- QIDDB.showIcon = true
- QIDDB.showitemType = true
- QIDDB.addTopLine = true
- QIDDB.addBotLine = true
- QIDDB.QualityIDVersion = "3.11"
- --Run once when first loaded.
- QID = CreateFrame("Frame", "QID")
- QID:RegisterEvent("ADDON_LOADED")
- --DEFAULT_CHAT_FRAME:AddMessage("|cff00dd88" .. "QualityID: v."..QIDDB.QualityIDVersion.." enabled! For options type /qid.");
- function QualityID:InitializeDB()
- if (not (QIDDB)) then DEFAULT_CHAT_FRAME:AddMessage("Setting up QIDDB.") end
- if (not (QIDDB)) then QIDDB = {} end
- if (not (QIDDB.enabled)) then QIDDB.enabled = self.enabled end
- if (not (QIDDB.showId)) then QIDDB.showId = self.showId end
- if (not (QIDDB.showitemLvl)) then QIDDB.showitemLvl = self.showitemLvl end
- if (not (QIDDB.showStackCount)) then QIDDB.showStackCount = self.showStackCount end
- if (not (QIDDB.showIcon)) then QIDDB.showIcon = self.showIcon end
- if (not (QIDDB.showitemType)) then QIDDB.showitemType = self.showitemType end
- if (not (QIDDB.addTopLine)) then QIDDB.addTopLine = self.addTopLine end
- if (not (QIDDB.addBotLine)) then QIDDB.addBotLine = self.addBotLine end
- if (not (QIDDB.QualityIDVersion)) then QIDDB.QualityIDVersion = self.QualityIDVersion end
- end
- function QualityID:OnEvent(event, arg1)
- if event == 'ADDON_LOADED' and arg1 == 'QualityID' then
- QualityID:InitializeDB();
- end
- end
- function chat(text)
- if(type(text) == "boolean") then
- if(text) then
- text = "True";
- else
- text = "False";
- end
- end
- if(text ~= nil) then
- DEFAULT_CHAT_FRAME:AddMessage("|cff00dd88" .. text .. "|r");
- end
- end
- SLASH_QUALITYID1 = "/qualityid"
- SLASH_QUALITYID2 = "/qid"
- -- SlashCmdList["SLASHCMD"] = function (msg, editBox) end; <--- blizz function for 3.0
- SlashCmdList["QUALITYID"] = function(msg)
- QualityID_SlashCommandHandler(msg);
- end
- --slashcommand functions
- function QualityID_SlashCommandHandler(msg)
- if(msg ~= "") or (msg~= "help") then
- chat("QualityID: " .. msg .. " toggled.");
- end
- if(msg:lower() == "toggle") then
- QIDDB.enabled = not QIDDB.enabled;
- elseif(msg:lower() == "on") then
- QIDDB.enabled = true;
- elseif(msg:lower() == "off") then
- QIDDB.enabled = false;
- elseif(msg:lower() == "id") then
- QIDDB.showid = not QIDDB.showid;
- elseif(msg:lower() == "ilvl") then
- QIDDB.showitemLvl = not QIDDB.showitemLvl;
- elseif(msg:lower() == "stack") then
- QIDDB.showStackCount = not QIDDB.showStackCount;
- elseif(msg:lower() == "itemtype") then
- QIDDB.showitemType = not QIDDB.showitemType;
- elseif(msg:lower() == "icon") then
- QIDDB.showIcon = not QIDDB.showIcon;
- elseif(msg:lower()== "topline") then
- QIDDB.addTopLine = not QIDDB.addTopLine;
- elseif(msg:lower()== "botline") then
- QIDDB.addBotLine = not QIDDB.addBotLine;
- elseif(msg == "") or (msg == "help") then
- chat("QualityID options: /qid {toggle | on | off}");
- chat("/qid id {toggle} ");
- chat("/qid ilvl {toggle} ");
- chat("/qid stack {toggle}");
- chat("/qid itemtype {toggle}");
- chat("/qid icon {toggle}");
- chat("/qid topline {toggle}");
- chat("/qid botline {toggle}");
- end
- end
- local origs = {}
- --Thanks to jnwhiteh for the code that finally removed the double info in recipe tooltips
- local lineAdded = false
- --calls id, ilvl, stkct, and type for our tooltip.
- local function OnTooltipSetItem(frame, ...)
- local name, link = frame:GetItem()
- if not link then return end
- if QIDDB.enabled and link then
- local _, _, id, id2 = strfind(link, "item:(%d+).+:(.+:.+)%[")
- --While not all returns will be called, all are listed for personal reference.
- local name,link,quality,ilvl,reqLevel,type,subType,stackCount = GetItemInfo(link)
- local rarity = select(3,GetItemInfo(id))
- if not rarity then return end
- --Tooltip info
- if link and GetItemInfo(link) and (rarity) then
- local r, g , b, hex = GetItemQualityColor(rarity)
- if not lineAdded then
- if QIDDB.addTopLine then
- frame:AddLine(" ")
- end
- if QIDDB.showid then
- frame:AddLine( "Item ID: |c"..hex..id.."|r")
- end
- if QIDDB.showitemLvl then
- frame:AddLine( "Item Lvl: |c"..hex..ilvl.."|r")
- end
- if QIDDB.showitemType then
- frame:AddLine( ""..type..": |c"..hex..subType.."|r")
- end
- if QIDDB.showStackCount and stackCount ~= 1 then
- frame:AddLine( "Stacks in lots of |c"..hex..stackCount.."|r")
- end
- if QIDDB.addBotLine then
- frame:AddLine(" ")
- end
- lineAdded = true
- end
- end
- end
- if origs[frame] then
- return origs[frame](frame, ...)
- end
- end
- --Add item icon to the tooltip.
- --Tooltip code yanked from Tuller's Tipachu.
- local function hookTip(frame, ...)
- local _G = getfenv(0)
- local set = frame:GetScript('OnTooltipSetItem')
- frame:SetScript('OnTooltipSetItem', function(self, ...)
- local link = select(2, self:GetItem())
- if link and GetItemInfo(link) then
- --make sure the icon does not display twice on recipies, which fire OnTooltipSetItem twice
- local text = _G[self:GetName() .. 'TextLeft1']
- if QIDDB.showIcon and text and text:GetText():sub(1, 2) ~= '|T' then
- text:SetFormattedText('|T%s:%d|t%s', GetItemIcon(link), 36, text:GetText())
- end
- end
- if set then
- return set(self, ...)
- end
- end)
- end
- hookTip(GameTooltip)
- hookTip(ItemRefTooltip)
- hookTip(ShoppingTooltip1)
- hookTip(ShoppingTooltip2)
- local function OnTooltipCleared(frame, ...)
- lineAdded = false
- end
- --Hookers of the standard GameTooltip variety.
- for _,frame in pairs{GameTooltip, ItemRefTooltip, ShoppingTooltip1, ShoppingTooltip2} do
- origs[frame] = frame:GetScript("OnTooltipSetItem")
- GameTooltip:HookScript("OnTooltipSetItem", OnTooltipSetItem)
- GameTooltip:HookScript("OnTooltipCleared", OnTooltipCleared)
- frame:SetScript("OnTooltipSetItem", OnTooltipSetItem)
- end
- -- AtlasLootTooltip flavored Hookers, if that's what you're into ;)!
- --AtlasLootTooltip:HookScript("OnTooltipSetItem", OnTooltipSetItem)
- --AtlasLootTooltip:HookScript("OnTooltipCleared", OnTooltipCleared)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement