WoWInterface SVN PhanxMod

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk
    from Rev 50 to Rev 51
    Reverse comparison

Rev 50 → Rev 51

CharacterFrame.lua
2,7 → 2,7
PhanxCharacterFrame
Shows durability, item level, and missing gems, enchants, sockets,
and upgrades on item slots in the character window.
 
 
Copyright (c) 2014 Phanx <addons@phanx.net>. All rights reserved.
Do not redistribute. Code reuse OK as long as neither my name nor
the name of this addon are used. Email if you have questions.
70,74 → 70,8
slot.textTop:SetTextColor(1, 0.2, 0.2)
end
 
local gemCounter = setmetatable({}, { __index = function(t, i)
local gem = CreateFrame("Button", nil, CharacterModelFrame)
gem:SetSize(16, 16)
 
local icon = gem:CreateTexture(nil, "ARTWORK")
icon:SetAllPoints()
icon:SetTexCoord(0.05, 0.95, 0.05, 0.95)
gem:SetNormalTexture(icon)
 
local text = gem:CreateFontString(nil, "OVERLAY", "NumberFontNormalSmall")
text:SetPoint("LEFT", gem, "RIGHT", 1, 1)
gem:SetFontString(text)
 
if i > 1 then
gem:SetPoint("BOTTOMLEFT", t[i-1], "TOPLEFT", 0, 1)
else
gem:SetPoint("BOTTOMLEFT", 3, 0)
end
 
t[i] = gem
return gem
end })
 
------------------------------------------------------------------------
 
-- Data copied from LibItemUpgradeInfo-1.0 by eridius
-- Excludes fully upgraded IDs, eg. 4/4
local canUpgrade = {
[373] = true,
[375] = true,
[376] = true,
[379] = true,
[445] = true,
[446] = true,
[451] = true,
[453] = true,
[454] = true,
[456] = true,
[458] = true,
[459] = true,
[460] = true,
[461] = true,
[465] = true,
[466] = true,
[468] = true,
[469] = true,
[470] = true,
[471] = true,
[491] = true,
[492] = true,
[493] = true,
[494] = true,
[495] = true,
[496] = true,
[497] = true,
[498] = true,
[504] = true,
[506] = true,
}
 
local function tonumberall(n, ...)
if select("#", ...) == 0 then
return tonumber(n)
else
return tonumber(n), tonumberall(...)
end
end
 
local function GetGradientColor(perc)
local relperc = perc * 2 % 1
return (perc > 0.5 and 1 - relperc or 1), (perc < 0.5 and relperc or 1), 0
145,60 → 79,39
 
------------------------------------------------------------------------
 
local GetNumSockets
local NumSockets, EffectiveItemLevel
do
local name = "PhanxModScanningTooltip"..random(100000, 10000000)
 
local name, left, textures = "PhanxModScanningTooltip"..random(100000, 10000000), {}, {}
local tooltip = CreateFrame("GameTooltip", name, UIParent, "GameTooltipTemplate")
tooltip:SetOwner(UIParent, "ANCHOR_NONE")
 
local textures = {}
for i = 1, 10 do textures[i] = _G[name.."Texture"..i] end
for i = 1, 10 do left[i] = _G[name.."TextLeft"..i] end
 
function GetNumSockets(slot, link)
if slot then
tooltip:SetInventoryItem("player", slot)
else
tooltip:SetHyperlink(link)
end
local NumSockets = setmetatable({}, { __index = function(t, link)
tooltip:SetHyperlink(link)
local n = 0
for i = 1, 10 do
if textures[i]:IsShown() then
n = n + 1
end
end
t[link] = n
return n
end
end
end })
 
------------------------------------------------------------------------
local ITEM_LEVEL_PATTERN = gsub(ITEM_LEVEL, "%%d", "(%%d+)")
 
local GEM_COLOR_TEXTURE = {
RED = "Interface\\Icons\\INV_Jewelcrafting_DragonsEye05", -- "Interface\\Icons\\INV_Misc_CutGemSuperior6",
YELLOW = "Interface\\Icons\\INV_Jewelcrafting_DragonsEye03", -- "Interface\\Icons\\INV_Misc_CutGemSuperior",
BLUE = "Interface\\Icons\\INV_Jewelcrafting_DragonsEye04", -- "Interface\\Icons\\INV_Misc_CutGemSuperior2",
PRISMATIC = "Interface\\Icons\\INV_Jewelcrafting_DragonsEye02",
}
 
local GetGemColors
do
local RED, BLUE, YELLOW, PURPLE, GREEN, ORANGE, META, SIMPLE, PRISMATIC, COGWHEEL = GetAuctionItemSubClasses(8)
 
local isRed = { [RED] = 1, [PURPLE] = 1, [ORANGE] = 1 }
local isYellow = { [YELLOW] = 1, [GREEN] = 1, [ORANGE] = 1 }
local isBlue = { [BLUE] = 1, [PURPLE] = 1, [GREEN] = 1 }
 
function GetGemColors(id)
if not id then
return 0, 0, 0, 0
local EffectiveItemLevel = setmetatable({}, { __index = function(t, link)
tooltip:SetHyperlink(link)
for i = 2, 3 do
local iLevel = strmatch(left[i]:GetText() or "", ITEM_LEVEL_PATTERN)
if iLevel then
iLevel = tonumber(iLevel)
t[link] = iLevel
return iLevel
end
end
local _, _, _, _, _, _, color = GetItemInfo(id)
if color == PRISMATIC then
return 1, 1, 1, 1
else
return isRed[color] or 0, isYellow[color] or 0, isBlue[color] or 0, 0
end
end
end })
end
 
------------------------------------------------------------------------
238,11 → 151,15
slot.textBottom:SetFormattedText("%d%%", perc * 100)
slot.textBottom:SetTextColor(GetGradientColor(perc))
else
local item = GetInventoryItemLink("player", slot.id)
local _, _, quality, level = GetItemInfo(item or 1)
local link = GetInventoryItemLink("player", slot.id)
local _, _, quality, level = GetItemInfo(link or 0)
if quality and quality > 1 then
local _, _, _, _, _, _, _, _, _, _, upgradeTypeID, _, numBonusIDs, allTheIDs = strsplit(":", strmatch(link, "|Hitem:(.-)|h"), 15)
if numBonusIDs ~= "0" or quality == LE_ITEM_QUALITY_HEIRLOOM then
level = EffectiveItemLevel[link]
end
local color = QualityColors[quality]
slot.textBottom:SetText(level > 1 and level or "")
slot.textBottom:SetText(level and level > 1 and level or "")
slot.textBottom:SetTextColor(color.r, color.g, color.b)
slot.frame.IconBorder:SetVertexColor(color.r, color.g, color.b)
slot.frame.IconBorder:Show()
262,9 → 179,9
local alert = " "
if itemLink then
--print("Checking item:", itemLink)
local _, itemID, enchantID, gem1, gem2, gem3, gem4, _, _, _, _, upgradeID = strsplit(":", strmatch(itemLink, "|H(.-)|h"))
local _, itemID, enchantID, gem1, gem2, gem3, gem4 = strsplit(":", strmatch(itemLink, "|H(.-)|h"))
local numGems = (gem1 == "0" and 0 or 1) + (gem2 == "0" and 0 or 1) + (gem3 == "0" and 0 or 1) + (gem4 == "0" and 0 or 1)
local numSockets = GetNumSockets(slot.id)
local numSockets = NumSockets[itemLink]
if numGems < numSockets then
--print(" Missing", numSockets - numGems, "gems")
alert = alert .. (numSockets - numGems)
273,52 → 190,9
--print(" Missing enchantment")
alert = alert .. ENCHANT_ABBREV
end
if slot.canAddSocket and numSockets == GetNumSockets(nil, itemLink) then
--print(" Missing added socket")
alert = alert .. SOCKET_ABBREV
end
if canUpgrade[tonumber(upgradeID)] then
--print(" Missing upgrade")
alert = alert .. UPGRADE_ABBREV
end
 
gem1, gem2, gem3, gem4 = GetInventoryItemGems(slot.id)
local r1, y1, b1, p1 = GetGemColors(gem1)
local r2, y2, b2, p2 = GetGemColors(gem2)
local r3, y3, b3, p3 = GetGemColors(gem3)
local r4, y4, b4, p4 = GetGemColors(gem4)
r = r + r1 + r2 + r3 + r4
y = y + y1 + y2 + y3 + y4
b = b + b1 + b2 + b3 + b4
p = p + p1 + p2 + p3 + p4
end
slot.textTop:SetText(alert)
end
 
local i = 1
if p > 0 then
gemCounter[i]:SetNormalTexture(GEM_COLOR_TEXTURE.PRISMATIC)
gemCounter[i]:SetText(p)
i = i + 1
end
if b > 0 then
gemCounter[i]:SetNormalTexture(GEM_COLOR_TEXTURE.BLUE)
gemCounter[i]:SetText(b)
i = i + 1
end
if y > 0 then
gemCounter[i]:SetNormalTexture(GEM_COLOR_TEXTURE.YELLOW)
gemCounter[i]:SetText(y)
i = i + 1
end
if r > 0 then
gemCounter[i]:SetNormalTexture(GEM_COLOR_TEXTURE.RED)
gemCounter[i]:SetText(r)
i = i + 1
end
for j = i, #gemCounter do
gemCounter[j]:Hide()
end
end
 
CharacterFrame:HookScript("OnShow", function()