--###################### |
-- Interface: 20400 |
-- Interface: 20400 |
-- Title: QualityID |
-- Notes: Displays an items ID and Level in the color of the item's quality. |
-- License: GNUv2GPL |
-- Author: Anaral |
-- Version: 1.00.09 |
-- Version: 2.05.00.wowi:revision |
--####################### |
|
QualityID = {} |
local QualityIDVersion = "1.00.09"; |
DEFAULT_CHAT_FRAME:AddMessage("QualityID: v "..QualityIDVersion.." enabled!",0,0,0) |
--future sv |
QualityID_DB = {} |
local debug = true; |
local enabled = true; |
local showStackCount = true; |
local showIcon = true; |
local showType = true; |
local QualityIDVersion = "|cff00dd88".."v 2.05.00.wowi:revision |r"; |
|
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("|cffe8cc01" .. text ); |
end |
end |
chat("QualityID: "..QualityIDVersion.."|cffe8cc01".." enabled! Type " .."|cff00dd88".."/qualityid" .."|cffe8cc01".." or ".."|cff00dd88".. "/qid " .."|cffe8cc01".."for toggle commands.") |
|
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 |
|
function QualityID_SlashCommandHandler(msg) |
if(msg ~= "") then |
chat("QualityID: " .. msg .. " toggled."); |
end |
if(msg:lower() == "toggle") then |
enabled = not enabled; |
elseif(msg:lower() == "on") then |
enabled = true; |
elseif(msg:lower() == "off") then |
enabled = false; |
elseif(msg:lower() == "stack") then |
showStackCount = not showStackCount; |
elseif(msg:lower() == "type") then |
showType = not showType; |
elseif(msg:lower() == "icon") then |
showIcon = not showIcon; |
elseif(msg == "") then |
chat("QualityID Options: /qid {toggle | on | off}"); |
chat("/qid stack {toggle}"); |
chat("/qid type {toggle}"); |
chat("/qid icon {toggle}"); |
end |
end |
|
local origs = {} |
|
local function OnTooltipSetItem(frame, ...) |
local name, link = frame:GetItem() |
|
if link then |
if enabled and link then |
local _, _, id, id2 = strfind(link, "item:(%d+).+:(.+:.+)%[") |
local name,link,quality,ilvl = GetItemInfo(id) |
--Add text |
--While not all returns will be called, all are listed for reference. |
local name,link,quality,ilvl,reqLevel,type,subType,stackCount = GetItemInfo(id) |
-- frame:AddLine(" ") |
frame:AddLine( "Item ID: "..ITEM_QUALITY_COLORS[quality].hex..id) |
frame:AddLine( "Item Lvl: "..ITEM_QUALITY_COLORS[quality].hex..ilvl) |
if showStackCount and stackCount > 2 then |
frame:AddLine( "Stacks in lots of "..ITEM_QUALITY_COLORS[quality].hex..stackCount) |
end |
if showType then |
frame:AddLine( ""..type..": "..ITEM_QUALITY_COLORS[quality].hex..subType) |
end |
frame:AddLine(" ") |
frame:AddDoubleLine( "Item ID:" , ITEM_QUALITY_COLORS[quality].hex..id) |
frame:AddDoubleLine( "Item Level:" , ITEM_QUALITY_COLORS[quality].hex..ilvl) |
end |
if origs[frame] then |
return origs[frame](frame, ...) |
end |
end |
|
--Add item icon to the tooltip. |
local function hookItem(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 |
local text = _G[self:GetName() .. 'TextLeft1'] |
if showIcon and text and text:GetText():sub(1, 2) ~= '|T' then --make sure the icon does not display twice on recipies, which fire OnTooltipSetItem twice |
text:SetFormattedText('|T%s:%d|t%s', GetItemIcon(link), 36, text:GetText()) |
end |
end |
|
if set then |
return set(self, ...) |
end |
end) |
end |
hookItem(GameTooltip) |
hookItem(ItemRefTooltip) |
hookItem(ShoppingTooltip1) |
hookItem(ShoppingTooltip2) |
|
for _,frame in pairs{GameTooltip, ItemRefTooltip, ShoppingTooltip1, ShoppingTooltip2} do |
origs[frame] = frame:GetScript("OnTooltipSetItem") |
frame:SetScript("OnTooltipSetItem", OnTooltipSetItem) |
end |
|