Thread Tools Display Modes
07-31-13, 04:02 PM   #1
zereissen
A Defias Bandit
Join Date: Jul 2013
Posts: 2
Replace text in Item Tooltips with Icons

Hello,

I have been looking for an add-on for some time that would simplify item tooltips, something that would replace the words "Strength", "Stamina", "Haste" etc with icons. If you could imagine the smiley here as the chosen picture for strength, instead of saying "+1,000 Strength" an item would have the following in its tooltip:

+1,000

It's not that they're difficult to read, I would simply personally like the added convenience of being able to tell what an item is from a very quick glance. I don't know if it's because I'm getting old, but twice now I've gone to equip an item that I thought had strength on it only to find out it instead had intellect.
  Reply With Quote
07-31-13, 04:44 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Quick drycoded example:

Code:
local replacements = {
    ["(%d) Agility"] = "%1 |TInterface\\AddOns\\MyAddon\\Icons\\mad:0|t",
    ["(%d) Strength"] = "%1 |TInterface\\AddOns\\MyAddon\\Icons\\smile:0|t",
}

local function ReplaceStatsWithIcons(tooltip)
    local name = tooltip:GetName()
    for i = 2, tooltip:NumLines() do -- Line 1 is always the item name, so skip it.
        local line = _G[name.."TextLeft"..i]
        local text = line:GetText()
        for k, v in pairs(replacements) do
            text = gsub(text, k, v)
        end
        line:SetText(text)
    end
    tooltip:Show()
end

GameTooltip:HookScript("OnTooltipSetItem", ReplaceStatsWithIcons)
ItemRefTooltip:HookScript("OnTooltipSetItem", ReplaceStatsWithIcons)
-- Add other tooltips here if you find you need them.
Alternatively, you could just give each stat a unique color, using ShinyStats or something similar, instead of replacing them with icons.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.

Last edited by Phanx : 08-03-13 at 08:35 PM. Reason: Fixed code.
  Reply With Quote
08-01-13, 03:22 PM   #3
zereissen
A Defias Bandit
Join Date: Jul 2013
Posts: 2
Thank you! I've considered one of the ones that changes the stats' colors, but thought it would be cooler to have icons instead. Thank you for your time and take care.
  Reply With Quote
08-03-13, 06:35 AM   #4
Malsomnus
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Apr 2013
Posts: 203
Hmmm, I tried this code and it doesn't seem to work, it just displays the path instead of an image. What could be the problem?
(I made sure to use a path to an image I actually have, of course)
__________________
SanityCheck - If you've ever said the words "Sorry, I forgot" then you need this add-on.

Remember, every time you post a comment on an add-on, a kitten gets its wings!
  Reply With Quote
08-03-13, 07:32 AM   #5
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
Originally Posted by Malsomnus View Post
Hmmm, I tried this code and it doesn't seem to work, it just displays the path instead of an image. What could be the problem?
(I made sure to use a path to an image I actually have, of course)
Try changing the lookup table to the following:

Code:
local replacements = {
    ["(%d) Agility"] = "%1 |TInterface\\AddOns\\MyAddon\\Icons\\mad:0|t",
    ["(%d) Strength"] = "%1 |TInterface\\AddOns\\MyAddon\\Icons\\smile:0|t",
}
This assumes you are using square icons, if not you will have to change the format.

http://wowpedia.org/UI_escape_sequences#Textures
  Reply With Quote
08-03-13, 08:34 AM   #6
Malsomnus
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Apr 2013
Posts: 203
That worked
Also, thanks for the link!
__________________
SanityCheck - If you've ever said the words "Sorry, I forgot" then you need this add-on.

Remember, every time you post a comment on an add-on, a kitten gets its wings!
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Search/Requests » Replace text in Item Tooltips with Icons


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off