WoWInterface SVN QualityID

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 10 to Rev 11
    Reverse comparison

Rev 10 → Rev 11

QID Tooltip.png Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream
trunk/QualityID/QualityID.lua
1,35 → 1,117
--######################
-- 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
 
trunk/QualityID/QualityID.toc
3,7 → 3,8
## Notes: Displays an items ID and Level in the color of the item's quality.
## License: GNUv2GPL
## Author: Anaral
## Version: 1.0.wowi:revision
## Version: 2.05.00.wowi:revision
## SavedVariables: QualityID_DB
## X-Category: Interface Enhancements
 
QualityID.lua
\ No newline at end of file