/trunk
--###################### |
-- Interface: 30000 |
-- Interface: 31000 |
-- 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.05 |
-- Version: 3.10 |
--####################### |
QualityID = {} |
QIDDB = { |
enabled = true; |
showid = true; |
showStackCount = true; |
showIcon = true; |
showType = true; |
} |
addTopTooltip = true; |
addBotTooltip = false; |
QualityIDVersion = "3.10"; |
}; |
QIDDB.enabled = true |
QIDDB.showid = true |
QIDDB.showStackCount = true |
QIDDB.showIcon = true |
QIDDB.showitemType = true |
QIDDB.QualityIDVersion = "3.05" |
QIDDB.addTopTooltip = true |
QIDDB.addBotTooltip = false |
QIDDB.QualityIDVersion = "3.10" |
--For testing if version is doubling info, if it shows twice, then we are sad pandas. |
--DEFAULT_CHAT_FRAME:AddMessage("|cff00dd88" .. "QualityID: v"..QIDDB.QualityIDVersion.." enabled!") |
function QualityID:CheckSavedVars() |
--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.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.addTopTooltip)) then QIDDB.addTopTooltip = self.addTopTooltip end |
if (not (QIDDB.addBotTooltip)) then QIDDB.addBotTooltip = self.addBotTooltip end |
end |
function QualityID:VARIABLES_LOADED() |
QualityID:CheckSavedVars() |
function QualityID:OnEvent(event, arg1) |
if event == 'ADDON_LOADED' and arg1 == 'QualityID' then |
QualityID:InitializeDB(); |
end |
end |
function chat(text) |
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 |
end |
--slashcommand functions |
function QualityID_SlashCommandHandler(msg) |
if(msg ~= "") then |
chat("QualityID: " .. msg .. " toggled."); |
end |
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.showitemType = not QIDDB.showitemType; |
elseif(msg:lower() == "icon") then |
QIDDB.showIcon = not QIDDB.showIcon; |
elseif(msg == "") then |
chat("QualityID options: /qid {toggle | on | off}"); |
elseif(msg:lower()== "toptooltip") then |
QIDDB.addTopTooltip = not QIDDB.addTopTooltip; |
elseif(msg:lower()== "bottooltip") then |
QIDDB.addBotTooltip = not QIDDB.addBotTooltip; |
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 toptooltip {toggle}"); |
chat("/qid bottooltip {toggle}"); |
end |
end |
local origs = {} |
--adds id, ilvl, stkct, and type |
--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(id) |
--text that you see in the tooltip |
frame:AddLine(" ") |
if quality then |
if id and QIDDB.showid then |
frame:AddLine( "Item ID: "..ITEM_QUALITY_COLORS[quality].hex..id) |
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 not lineAdded then |
if QIDDB.addTopTooltip then |
frame:AddLine(" ") |
end |
if link and GetItemInfo(link) and (rarity) then |
local r, g , b, hex = GetItemQualityColor(rarity) |
if QIDDB.showid then |
frame:AddLine( "Item ID: "..hex..id) |
end |
if QIDDB.showitemLvl then |
frame:AddLine( "Item Lvl: "..hex..ilvl) |
end |
if QIDDB.showitemType then |
frame:AddLine( ""..type..": "..hex..subType) |
end |
if QIDDB.showStackCount and stackCount ~= 1 then |
frame:AddLine( "Stacks in lots of "..hex..stackCount) |
end |
if QIDDB.addBotTooltip then |
frame:AddLine(" ") |
end |
lineAdded = true |
end |
if ilvl and QIDDB.showitemLvl then |
frame:AddLine( "Item Lvl: "..ITEM_QUALITY_COLORS[quality].hex..ilvl) |
end |
if subType and QIDDB.showitemType then |
frame:AddLine( ""..type..": "..ITEM_QUALITY_COLORS[quality].hex..subType) |
end |
if stackCount and QIDDB.showStackCount and stackCount > 2 then |
frame:AddLine( "Stacks in lots of "..ITEM_QUALITY_COLORS[quality].hex..stackCount) |
end |
end |
frame:AddLine(" ") |
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'] |
--make sure the icon does not display twice on recipies, which fire OnTooltipSetItem twice |
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 |
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) |
--Run once when first loaded. |
QID = CreateFrame("Frame", "QID") |
QID:RegisterEvent("VARIABLES_LOADED") |
QID:SetScript("OnEvent", function(self, event, ...) QualityID[event](QualityID, event, ...) end) |
DEFAULT_CHAT_FRAME:AddMessage("|cff00dd88" .. "QualityID: v"..QIDDB.QualityIDVersion.." enabled!"); |
## Interface: 30000 |
## Interface: 31000 |
## Title: QualityID |
## Notes: Displays an items basic info in the item's quality color. |
## Author: Anaral |
## Version: 3.05.wowi:revision |
## Version: 3.05.@project-revision@ |
## Version: 3.10.wowi:revision |
## Version: 3.10.@project-revision@ |
## SavedVariables: QIDDB |
## X-Category: Interface Enhancements |
##Core## |
QualityID.lua |
##Addon Not For Distribution## |
HoverTips.lua |